עבור לתוכן

לא נכנס ללולאה PHP

Featured Replies

פורסם

מה המצב חברים

יש לי בעיה של כניסת משתמשים באתר שלי...

אצלי על המחשב הכל עובד טוב וחלק

אבל על השרת אני לא מצליח להיכנס לאתר או לירשום משתמש חדש.

זה הקוד

הבעיה היא שהקוד מגיע עד ללולאה ומדלג עליה

עשיתי בדיקות עם ECHO בכל מיני מקומות זה לא נכנס ללולאה.


<?php
require("db.php");



//
//
//================================================================================================
//
// login



if ( isset($_POST['login']) && $_POST['login']=="login" )
// did data entered?
{
//if ( isset($_POST['textuser']) && isset($_POST['textpass']) )
// none of the slots can be blank?
//{
$res = mysql_query("SELECT * from users",$link);
$canput = 0;

while( $row = mysql_fetch_array($res) )
{
if ( !strcmp($row['username'],$_POST['textuser']) && !strcmp($row['password'],$_POST['textpass']) )
// if password and user name true
{
$canput = 1;
break;
}
}

if ( $canput )
{

$_SESSION['username'] = $row['username'];
$_SESSION['myid'] = $row['id'];
$_SESSION['login'] = '1';
$_SESSION['candidate']='0';
$_SESSION['myimg'] = $row['myimg'];
echo "You are signed in, thx you for login ".$_POST['textuser'];
//header('Location:../startpage/Nsummary.php');

}
else
{
echo "<font color='red'>שם המשתמש או הסיסמה לא נמצאים במערכת</font>";
echo "<br/>";
}

//}
}

// login
//
//==================================================================================================
//
// register

if ( isset($_POST['reg']) && $_POST['reg']=="reg" )
// Did data entered?
{
if ( $_POST['sex'] != ""/*isset($_POST['user']) && isset($_POST['pass']) && isset($_POST['conf'])*/ )
// None of the slots can be blank?
{
if ( !strcmp($_POST['textpass'],$_POST['textconfpass']) &&
$_POST['textpass']!=NULL && $_POST['textuser']!=NULL)
// Did the password match? and user not null
{
$query1 = "SELECT username from users";
$res = mysql_query($query1,$link) or die(mysql_error());
$canput = 0;
while( $row = mysql_fetch_array($res) )
{
if ( !strcmp($row['username'],$_POST['textuser']) )
{
$canput = 1;
break;
}
}
if ( !$canput )
{
$query = "INSERT INTO users (username, password,firstname,lastname,Email,city,year,sex)
VALUES ('".$_POST['textuser']."', '".$_POST['textpass']."', '".$_POST['textfirst']."' , '".$_POST['textlast']."' , '".$_POST['textemail']."' , '".$_POST['textcity']."' , '".$_POST['textyear']."' , '".$_POST['textsex']."')";
$res = mysql_query($query ,$link);
//echo mysql_errno($link) . ": " . mysql_error($link) . "\n";
echo "You are signed in, thx you for registering ".$_POST['textuser'];
$_SESSION['login'] = 'yes';
$_SESSION['username'] = $_POST['textuser'];
$_SESSION['candidate']='';
//header('Location:../startpage/Nsummary.php');

}
else
{
echo "<font color='red'><h3><b>שם משתמש קיים במערכת, בחר שם אחר</b></h3></font>";
}
}
else
{
echo "<font color='red'><h3><b>בדוק את הסיסמה או את שם המשתמש</b></h3></font>";
}
}
else
{
echo "<font color='red'><h3><b>הכנס לנתונים זכר או נקבה</b></h3></font>";
}
}

// register
//
//======================================================================================================
//
//



//
//
//======================================================================================================
//
//
mysql_close();
?>

תודה לעוזרים

פורסם

התנאי הזה

$row = mysql_fetch_array($res)

לא מחזיר TRUE או FALSE

מה אתה רוצה לבדוק שם ?

ודבר שני אתה לא יכול לגשת למערך כך :

$row['username']

אם השתמשת בfetch_array . אלא רק עם אינקסים מספריים

אתה צריך להשתמש בmysql_fetch_assoc

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים