I am executing following program but value of 'pass' is not being received. Please help me. my code is following. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php $con = mysql_connect("localhost","sanganak_manish","manish"); //$con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("sanganak_mydata",$con); $result = mysql_query("SELECT name,password from login where name='".$_POST[name]."' and password ='".$_POST[pass]."'"); //$num = mysql_numrows($result) if(mysql_numrows($result)) { echo "valid user"; } else { echo "not a valid user"; } //echo $row['name']; //echo $row['date_diff']; //echo $row['e_mail']; //$to = $row['e_mail']; //echo $to; mysql_close($con); ?> </body> </html>
my form code is following - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <div align="center"> <p>Index.php </p> <table width="100%" height="87" border="0"> <tr> <td width="71%" valign="top">LOGO</td> <td width="29%" valign="top">ADMINISRATOR PANEL </td> </tr> </table> <p> </p> <p>ADMINISTRATOR LOGIN </p> <table width="45%" border="0"> <tr> <td width="33%" valign="top"><p>USER NAME</p> <p>PASSWORD</p> </td> <td width="67%"><form name="form1" method="post" action="pass_check.php"> <p> <input type="text" name="name"> </p> <p> <input type="text" name="pass"> </p> <p> <input type="submit" name="Submit" value="Submit"> </p> </form></td> </tr> </table> <p> </p> <p> </p> </div> </body> </html>
And you're sure it isn't passed? Or does MySQL just not return a valid user? What output do you get when you run this: print_r($_POST); PHP: And please (really!) have a look at this page: www.php.net/mysql_real_escape_string (For your own security) EDIT: And please use [html] or [php] wrappers when posting code, so it's easier to read. http://forums.digitalpoint.com/misc.php?do=bbcode#php
I have used 'echo $_post[pass]' but it did not print anything. It is just returning not a valid user.
Try using quotes in your post values like this: $_POST['pass'] PHP: Do the other posted values show when you do print_r( $_POST ) ? Brew
Did you echo $_post[pass] or $_POST[pass]? (Note that POST should be all uppercase.) Your HTML form is correct, so the error must be in your PHP script. Would you mind giving me the output of this though? print_r($_POST); PHP: Just to see what you receive at all.