vasoftwaresolutions Posted March 12, 2008 Author Share Posted March 12, 2008 ok i put "mysql_error();" and it says error on line 48 that there is no $end.. does anyone know the code to end it? Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490150 Share on other sites More sharing options...
derrick1123 Posted March 12, 2008 Share Posted March 12, 2008 mysql_close(); Weird, I didn't think it would require this. Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490152 Share on other sites More sharing options...
phpSensei Posted March 12, 2008 Share Posted March 12, 2008 I don't know why but: $result=mysql_query($sql); Shouldn't that be: $result=mysql_query("$sql"); ??? That would make it read the string "$sql" not the query that the var contains. Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490153 Share on other sites More sharing options...
derrick1123 Posted March 12, 2008 Share Posted March 12, 2008 I don't know why but: $result=mysql_query($sql); Shouldn't that be: $result=mysql_query("$sql"); ??? That would make it read the string "$sql" not the query that the var contains. OH, ok thanks! Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490154 Share on other sites More sharing options...
vasoftwaresolutions Posted March 12, 2008 Author Share Posted March 12, 2008 mysql_close(); Weird, I didn't think it would require this. that didnt do anything.... but this is the error "Parse error: syntax error, unexpected $end in /home/pacifij1/public_html/bluewavesvirtual/checklogin.php on line 48" Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490155 Share on other sites More sharing options...
derrick1123 Posted March 12, 2008 Share Posted March 12, 2008 Can you post your checklogin.php now? Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490157 Share on other sites More sharing options...
vasoftwaresolutions Posted March 12, 2008 Author Share Posted March 12, 2008 ok i made a test account for you guys to check it out... here is the file.. http://bluewavesvirtual.com/index1.php user is BWA1001 password is 833699 Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490160 Share on other sites More sharing options...
phpSensei Posted March 12, 2008 Share Posted March 12, 2008 ok i made a test account for you guys to check it out... here is the file.. http://bluewavesvirtual.com/index1.php user is BWA1001 password is 833699 We need your current checklogin.php script, we can't fix this by just visiting the page Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490161 Share on other sites More sharing options...
vasoftwaresolutions Posted March 12, 2008 Author Share Posted March 12, 2008 that first page was the script Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490163 Share on other sites More sharing options...
phpSensei Posted March 12, 2008 Share Posted March 12, 2008 that first page was the script Any changes you made might have caused the error, post your current page for the checklogin.php Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490164 Share on other sites More sharing options...
vasoftwaresolutions Posted March 12, 2008 Author Share Posted March 12, 2008 ok <?php $host="localhost"; // Host name $username="pacifij1_blue"; // Mysql username $password="8336994895"; // Mysql password $db_name="pacifij1_blue"; // Database name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from signup form $callsign = $_POST['callsign']; $pwd = $_POST['pwd']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $sql="SELECT * FROM pilot WHERE callsign='$callsign' and pwd='$pwd'"; $result=mysql_query($sql) or die(mysql_error()); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count<0){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("callsign"); session_register("pwd"); session_register("first_name"); session_register("last_name"); header("location:login_success.php"); } else { mysql_error(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Loading</title> </head> <body> </body> </html> <?php mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490166 Share on other sites More sharing options...
phpSensei Posted March 12, 2008 Share Posted March 12, 2008 try <?php $host="localhost"; // Host name $username="pacifij1_blue"; // Mysql username $password="8336994895"; // Mysql password $db_name="pacifij1_blue"; // Database name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from signup form $callsign = $_POST['callsign']; $pwd = $_POST['pwd']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $sql="SELECT * FROM pilot WHERE callsign='$callsign' and pwd='$pwd'"; $result=mysql_query($sql) or die(mysql_error()); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count<0){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("callsign"); session_register("pwd"); session_register("first_name"); session_register("last_name"); header("location:login_success.php"); } else { mysql_error(); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Loading</title> </head> <body> </body> </html> <?php mysql_close(); ?> edit: You forgot a "}" closing bracket after the ELSE Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490168 Share on other sites More sharing options...
vasoftwaresolutions Posted March 12, 2008 Author Share Posted March 12, 2008 IT WORKS NOW.. but its not redirecting to the header Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490169 Share on other sites More sharing options...
derrick1123 Posted March 12, 2008 Share Posted March 12, 2008 Change: header("location:login_success.php"); to: echo "<head><title><meta http-equiv='refresh' content='5;url=login_success.php'></title></head>"; Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490172 Share on other sites More sharing options...
vasoftwaresolutions Posted March 12, 2008 Author Share Posted March 12, 2008 Nope.. its just showing a white page.. you guys can check.. i posted the user and password Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490175 Share on other sites More sharing options...
phpSensei Posted March 12, 2008 Share Posted March 12, 2008 Try <?php $host="localhost"; // Host name $username="pacifij1_blue"; // Mysql username $password="8336994895"; // Mysql password $db_name="pacifij1_blue"; // Database name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from signup form $callsign = $_POST['callsign']; $pwd = $_POST['pwd']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $sql="SELECT * FROM pilot WHERE callsign='$callsign' and pwd='$pwd'"; $result=mysql_query($sql) or die(mysql_error()); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count<0){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("callsign"); session_register("pwd"); session_register("first_name"); session_register("last_name"); header("location:login_success.php"); echo 'Login Worked'; } else { mysql_error(); echo 'Login Didnt Work'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Loading</title> </head> <body> </body> </html> <?php mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490179 Share on other sites More sharing options...
vasoftwaresolutions Posted March 12, 2008 Author Share Posted March 12, 2008 Login Didnt Work Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490183 Share on other sites More sharing options...
phpSensei Posted March 12, 2008 Share Posted March 12, 2008 Login Didnt Work Thats because of the if($count<0){ *dirty look to derrick * jk Try <?php $host="localhost"; // Host name $username="pacifij1_blue"; // Mysql username $password="8336994895"; // Mysql password $db_name="pacifij1_blue"; // Database name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from signup form $callsign = $_POST['callsign']; $pwd = $_POST['pwd']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $sql="SELECT * FROM pilot WHERE callsign='$callsign' and pwd='$pwd'"; $result=mysql_query($sql) or die(mysql_error()); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("callsign"); session_register("pwd"); session_register("first_name"); session_register("last_name"); header("location:login_success.php"); echo 'Login Worked'; } else { mysql_error(); echo 'Login Didnt Work'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Loading</title> </head> <body> </body> </html> <?php mysql_close(); ?> That little part basically means if $count echos any number under 0, then log the user in Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490189 Share on other sites More sharing options...
vasoftwaresolutions Posted March 12, 2008 Author Share Posted March 12, 2008 still didnt work Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490192 Share on other sites More sharing options...
derrick1123 Posted March 12, 2008 Share Posted March 12, 2008 My bad lol You might have to use: session_start(); Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490193 Share on other sites More sharing options...
phpSensei Posted March 12, 2008 Share Posted March 12, 2008 still didnt work We prevented a bug that may occur in the future, so lets give a pat on our backs. You should print out the username and password from the FORM, and the DB and see if they equal each other... <?php $host="localhost"; // Host name $username="pacifij1_blue"; // Mysql username $password="8336994895"; // Mysql password $db_name="pacifij1_blue"; // Database name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from signup form $callsign = $_POST['callsign']; $pwd = $_POST['pwd']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $sql="SELECT * FROM pilot WHERE callsign='$callsign' and pwd='$pwd'"; $result=mysql_query($sql) or die(mysql_error()); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row $row = mysql_fetch_array($result); echo 'Username Tried: ' .$callsign; echo 'Password Tried: ' .$pwd.'<br>'; echo 'Username DB: ' .$row['pwd']; echo 'Password DB: ' .$row['callsign'].'<br>'; if($count > 0){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("callsign"); session_register("pwd"); session_register("first_name"); session_register("last_name"); header("location:login_success.php"); echo 'Login Worked'; } else { mysql_error(); echo 'Login Didnt Work'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Loading</title> </head> <body> </body> </html> <?php mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490194 Share on other sites More sharing options...
ohdang888 Posted March 12, 2008 Share Posted March 12, 2008 i don't bother with counts.. i just would do... $sql="SELECT `id` FROM pilot WHERE callsign='$callsign' and pwd='$pwd'"; $result=mysql_query($sql) or die(mysql_error()); $id= mysql_fetch_array($result); if(empty($id['id'])){ echo failed} if(strlen($id['id']) > 0){ log in } it doesn't count rows... so if there was more than 1 password and username the same i'd be screwed... but i check for existing user names at registration, so that shouldn't be a problem Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490196 Share on other sites More sharing options...
phpSensei Posted March 12, 2008 Share Posted March 12, 2008 i don't bother with counts.. i just would do... $sql="SELECT `id` FROM pilot WHERE callsign='$callsign' and pwd='$pwd'"; $result=mysql_query($sql) or die(mysql_error()); $id= mysql_fetch_array($result); if(empty($id['id'])){ echo failed} if(strlen($id['id']) > 0){ log in } it doesn't count rows... so if there was more than 1 password and username the same i'd be screwed... but i check for existing user names at registration, so that shouldn't be a problem You would prevent that at the registration process, and your method takes a lifetime Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490198 Share on other sites More sharing options...
vasoftwaresolutions Posted March 12, 2008 Author Share Posted March 12, 2008 ok php sinsi i did what you said and it did this Username Tried: BWA1001Password Tried: 833699 Username DB: 833699Password DB: BWA1001 Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /home/pacifij1/public_html/bluewavesvirtual/checklogin.php:27) in /home/pacifij1/public_html/bluewavesvirtual/checklogin.php on line 36 Warning: Cannot modify header information - headers already sent by (output started at /home/pacifij1/public_html/bluewavesvirtual/checklogin.php:27) in /home/pacifij1/public_html/bluewavesvirtual/checklogin.php on line 40 Login Worked Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0 Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490203 Share on other sites More sharing options...
ohdang888 Posted March 12, 2008 Share Posted March 12, 2008 php sensi, my method or his??? Link to comment https://forums.phpfreaks.com/topic/95726-php-login/page/2/#findComment-490205 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.