PDA

View Full Version : سوال: مشکل در ارتباط فرم با mysql



rezvan.j
پنج شنبه 24 دی 1388, 19:48 عصر
سلام
من میخوام یه login بنویسم
در اعتبار نام کاربری وارد homepage بشه




فرم html
<td width="209"><form action="index1.php" method="post" >

<div> <input type="text" name="u" class="links" > نام کاربري </div>


<input type="text" name="p" class="links">
رمز عبور
<div> <input type="button" name="b1" value="

ورود " class="b">
<input type="button" name="b2" value="انصراف"

class="b"> </div>
</p>
</form>
</td>





کد php


<?php
$db=mysql_connect("localhost","root","");
if (!$db)
{
echo "can not connect to my sql ";
exit;
}
mysql_select_db("school");
$query="select * from student where Id_student='$_POST[u]' and shsh='$_POST

[p]'";
$result=mysql_query($query);
if(!$result)
{
echo "username is not valid";
exit;}
echo "welcome";
'<a href ="home.html"> </a>';
?>



البته اینطوری هم نوشتم اما بازم بی فایده



<?php
mysql_connect("localhost","root",""); //
mysql_select_db("school");
echo mysql_error();

if($_POST[u]=="" or $_POST[p]=="")
{echo "plz fill the item";}
else {$res=mysql_query("select * from student where id_student='$_POST[u]' and

shsh='$_POST[p]'");
if(mysql_num_rows($res)>0)
{session_start();
session_register;
session_register(p);
$row=mysql_fetch_assoc($res);
$_SESSION[u]=$row[id_student];
$_SESSION[p]=$row[shsh];
//echo $_SESSION[u];
//echo $_SESSION[p];
echo "welcome";}
else{header("locationignup2.html");}}



?>

پلیز هلپ می

rezvan.j
پنج شنبه 24 دی 1388, 21:02 عصر
session_start گذاشتم ولی error می ده