Re: Small Error in Login Script

From: Date: Tue, 01 Jul 2003 04:05:47 +0000
Subject: Re: Small Error in Login Script
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-153507@lists.php.net to get a copy of this message
hi, this is what i found... ---------------------------------- <? session_start(); error_reporting(E_ALL); if ( (isset($_POST['validuser'])) && (isset($_POST['password'])) ) { mysql_connect( 'localhost', 'abc', 'pwd' ) or die ( 'Unable to connect to server.' ); // Select database on MySQL server mysql_select_db( 'masterstream' ) or die ( 'Unable to select database' ); // Formulate the query $sql1 = "SELECT * from admin where admin.username = '$_POST[validuser]' AND admin.password = '$_POST[password]'"; $result1 = mysql_query($sql1) or die ( 'Database Error has occured.'); $num_results = mysql_num_rows($result1); if ($num_results == 1 ) { echo "Success!<br>"; if(!isset($_SESSION['validuser'])) $_SESSION['validuser'] = $_POST['validuser']; } else{ echo "Please try again later<br>"; } } ?> <html> <head> <title>ADMIN-LOGIN</title> </head> <? if (isset($_SESSION['validuser'])) { echo "You are already logged into the system !!!"; } else { echo "test"; } echo " <body bgcolor=\"aaaaaa\"> <form name=\"form1\" method=\"post\" action=\"ADMIN-LOGIN.php\"> <table width=\"713\" height=\"132\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\" bgcolor=\"#FFFFFF\"> <tr> <td width=\"787\" height=\"119\"> <table width=\"707\" border=\"1\" cellspacing=\"3\" cellpadding=\"2\"> <tr bgcolor=\"99ccff\"> <td colspan=\"2\"><div align=\"center\"><strong><font color=\"#FFFFFF\" size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">Please enter your Username and Password </font></strong></div></td> </tr> <tr bgcolor=\"#E7E7E7\"> <td width=\"214\"><strong><font color=\"#666666\" size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\">Login</font></strong></td> <td width=\"549\"><font size=\"1\"> <input name=\"validuser\" type=\"text\" id=\"validuser2\"> </font></td> </tr> <tr bgcolor=\"#E7E7E7\"> <td><strong><font color=\"#666666\" size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\">Password</font></strong></td> <td><font size=\"1\"> <input name=\"password\" type=\"password\" id=\"password\"> </font></td> </tr> <tr bgcolor=\"#E7E7E7\"> <td height=\"24\" colspan=\"2\"><div align=\"center\"> <input type=\"submit\" name=\"Submit\" value=\"Submit\"> </div></td> </tr> </table></td> </tr> </table> </form> "; ?> --------------------------------- regards, -shiva "Pushpinder Singh Garcha" <pgarcha@adelphia.net> wrote in message news:40A318AE-AB11-11D7-9FC9-000393874598@adelphia.net... Hello All, I am trying to setup a simple login script on my development server running Mac OS Jaguar. I keep getting an error Parse error: parse error in /Users/psgarcha/Sites/CRM/ADMIN-LOGIN.php on line 2. I am at a complete loss ! Here is the source code. Please help. ------------------------------------------------- <? session_start(); error_reporting(E_ALL); if ( (isset($_POST['validuser'])) && (isset($_POST['password'])) ) { mysql_connect( 'localhost', 'abc', 'pwd' ) or die ( 'Unable to connect to server.' ); // Select database on MySQL server // mysql_select_db( 'masterstream' ) or die ( 'Unable to select database' ); // Formulate the query // $sql1 = "SELECT * from admin where admin.username = "$_POST['validuser']" AND admin.password = "$_POST['password']""; $result1 = mysql_query($sql1) or die ( 'Database Error has occured.'); $num_results = mysql_num_rows($result1); if ($num_results == 1 ) { echo "Success!<br>"; if(!isset($_SESSION['validuser'])) $_SESSION['validuser'] = $_POST['validuser']; } else{ echo "Please try again later<br>"; } } ?> <html> <head> <title>ADMIN-LOGIN</title> </head> <? if (isset($_SESSION['validuser'])) { echo "You are already logged into the system !!!"; } else { echo "test"; } echo " <body bgcolor=\"aaaaaa\"> <form name=\"form1\" method=\"post\" action=\"ADMIN-LOGIN.php\"> <table width=\"713\" height=\"132\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\" bgcolor=\"#FFFFFF\"> <tr> <td width=\"787\" height=\"119\"> <table width=\"707\" border=\"1\" cellspacing=\"3\" cellpadding=\"2\"> <tr bgcolor=\"99ccff\"> <td colspan=\"2\"><div align=\"center\"><strong><font color=\"#FFFFFF\" size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">Please enter your Username and Password </font></strong></div></td> </tr> <tr bgcolor=\"#E7E7E7\"> <td width=\"214\"><strong><font color=\"#666666\" size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\">Login</font></strong></td> <td width=\"549\"><font size=\"1\"> <input name=\"validuser\" type=\"text\" id=\"validuser2\"> </font></td> </tr> <tr bgcolor=\"#E7E7E7\"> <td><strong><font color=\"#666666\" size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\">Password</font></strong></td> <td><font size=\"1\"> <input name=\"password\" type=\"password\" id=\"password\"> </font></td> </tr> <tr bgcolor=\"#E7E7E7\"> <td height=\"24\" colspan=\"2\"><div align=\"center\"> <input type=\"submit\" name=\"Submit\" value=\"Submit\"> </div></td> </tr> </table></td> </tr> </table> </form> "; ?> </body> </html> Thanks in advance. Pushpinder

« previous php.general (#153507) next »