
02-01-2009, 23:44
|
|
|
|
חבר מתאריך: 06.06.07
הודעות: 749
|
|
|
הכנסת נתונים
הקוד הבא מכניס לי נתונים של משתמש ל DB
הקוד מחזיר שהנתונים נכנסו בהצלחה
אבל לא נשמר כלום ב DB
האם יש לי טעות בקוד
תודה
קוד PHP:
<?php
require("db.php");
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` , `firatname` , `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 "You are signed in, thx you for registering ".$_POST['textuser']; //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>"; } } // // //================================================== ================================================== == // // mysql_close(); ?>
|