PDA

View Full Version : مشکل در فرم لاگین



rezajooni
سه شنبه 16 اردیبهشت 1393, 22:54 عصر
دوستان بعد از ساخت فرم لاگین پس از عضویت ، هنگام ورود ارور میده که نام کاربری یا رمز عبور اشتباه است در حالی که درسته.

این از فرم چک:


<?php

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
include './funcs/config.php';
$username=$_POST['username'];
$password=$_POST['password'];
$sucssecfull=FALSE;
if(strlen($username)>0 && strlen($password)>0){
$query = "SELECT * FROM `user` WHERE `username` =$username and `password` =$password ";
$result = mysql_query($query , $db_link);
$count = mysql_num_rows($result);
if($count==1){
$sucssecfull=TRUE;
}
}
if($sucssecfull==TRUE){
header("location: index.php");
} else {
header("location: login.php?type=error") ;
}
mysql_close ($db_link);

اینم کد submit


<?php
include './funcs/config.php';

$username=$_POST['username'];
$password1=$_POST['pwd1'];
$password2=$_POST['pwd2'];
$email=$_POST['email'];
$fname=$_POST['fname'];
$lname=$_POST['lname'];

$sucssecfull=FALSE;
if(strlen($username)>0 && strlen($password1)>0 && strlen($password2)>0){
if($password1==$password2){
$sql = "SELECT * FROM `user` WHERE `username` =$username ";
$result = mysql_query($sql , $db_link);
$count = mysql_num_rows($result);
if($count == 0){
$sql = "INSERT INTO `user`(`username`, `password`, `fname`, `lname`, `email`) VALUES ('$username', '$password1', '$fname', '$lname', '$email')";
mysql_query($sql , $db_link);
$sucssecfull=TRUE;
}
}
}
if($sucssecfull==TRUE){
header("location: index.php");
} else {
header("location: register.php");
}
mysql_close($db_link);