Help with unexpected T_ELSE |
Help with unexpected T_ELSE |
tyler.watkins |
May 24 2012, 01:53 PM
Post
#1
|
Novice Group: Members Posts: 27 Joined: 6-March 12 Member No.: 16,654 |
Parse error: syntax error, unexpected T_ELSE in /home/a3535994/public_html/login.php on line 121 I get this error message and idk why. I am trying to make a login system for my website. Here is my code. <?php $mysql_host = "***********"; $mysql_database = "*****"; $mysql_user = "*************"; $mysql_password = "*********"; $user = $_POST['username']; $password = $_POST['password']; $con = mysql_connect( "$mysql_host", "$mysql_user", "$mysql_password" ); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$mysql_database", $con) or die (mysql_error()); $login_user = mysql_query("SELECT username FROM user"); $login_pass = mysql_query("SELECT password FROM user"); if ('$login_user' === '$user' && '$login_pass' === '$password'); { ?> <!--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta name="generator" content="HTML Tidy for Linux (vers 6 November 2007), see www.w3.org"> <script type="text/javascript" src="enter.js"></script> <link href="style4.css" rel="stylesheet" media="all" type="text/css"> <script type="text/javascript"> function inputFocus(i){ if(i.value==i.defaultValue){ i.value=""; i.style.color=""; } } function inputBlur(i){ if(i.value==""){ i.value=i.defaultValue; i.style.color=""; } } </script> <title>BLOCKS-Minecraft Maps and More</title> <style type="text/css"> input.c2 {background-color:grey; text-style:times new roman;} div.c1 {text-align: center} </style> </head> <body> <!--CONTAINER--> <div class="container"> <div class="c1"> <div class="header"><br> <h1>BLOCKS</h1> <p>Minecraft Maps and More</p> </div> <!--LEFT SIDEBAR--> <div class="lsbar"> <hr width="95%"> <a href="home.html">Home</a> <hr width="95%"> <a href="http://blocks.forums.net.bz/">Forums</a> <hr width="95%"> <a href="team.html">Our Team</a> <hr width="95%"> <a href="tournaments.html">Tournaments</a> <hr width="95%"> <a href="downloads.html">Downloads</a> <hr width="95%"> <a href="register.html">Register</a> <hr width="95%"> <!--<a href="#">Help</a> <hr width="95%" color="black">--></div> <!--CONTENT--> <div class="content"> <div class="content-header c1"> <h1>What is Blocks?</h1> </div> <p>Welcome to Blocks. Here you can find and download Minecraft Maps and enter into awesome Minecraft Tournaments, oh and IT'S ALL FREE!!!</p> <div class="content-header c1"> <h1>What are the Tournaments?</h1> </div> <p>The tournaments you can enter here are unlike any other! If you enjoy minecraft, then you should sign up for this site. The tournaments could range from crafting something in a specified space to creating a whole map! Check out the <a href="tournaments.html">Tournaments</a> page for more information.</p> <div class="content-header c1"> <h1>When are the Tournaments?</h1> </div> <p>Check out the <a href="tournaments.html">Tournaments</a> page to find out when you can start siging up for tournaments and for a complete list of upcoming tournaments!</p> <div class="content-header c1"> <h1>Worm's Blog</h1> </div> <p>Check <a href="worm.html">Here</a> to see updates and to leave comments!</p> <br><br><br><br><br><br><br><br><br><br><br><br><br> </div> <!--RIGHT SIDEBAR--> <div class="rsbar-signin"> <h2>SIGN IN</h2> <br> <p>Logged In</p> <hr width="95%"> <h2>Why Register?</h2> <p>Registering with us will make you eligible to join our Minecraft Tournaments. You will also be entered into our mailings list and will recieve emails containing information on upcoming maps and tournaments.</p> </div> <!--FOOTER--> <center><div class="footer">©Blocks.netne.net</div></center> </div> </div> </body> </html> <!--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------> <?php } else { ?> <!--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta name="generator" content="HTML Tidy for Linux (vers 6 November 2007), see www.w3.org"> <script type="text/javascript" src="enter.js"></script> <link href="style4.css" rel="stylesheet" media="all" type="text/css"> <script type="text/javascript"> function inputFocus(i){ if(i.value==i.defaultValue){ i.value=""; i.style.color=""; } } function inputBlur(i){ if(i.value==""){ i.value=i.defaultValue; i.style.color=""; } } </script> <title>BLOCKS-Minecraft Maps and More</title> <style type="text/css"> input.c2 {background-color:grey; text-style:times new roman;} div.c1 {text-align: center} </style> </head> <body> <!--CONTAINER--> <div class="container"> <div class="c1"> <div class="header"><br> <h1>BLOCKS</h1> <p>Minecraft Maps and More</p> </div> <!--LEFT SIDEBAR--> <div class="lsbar"> <hr width="95%"> <a href="home.html">Home</a> <hr width="95%"> <a href="http://blocks.forums.net.bz/">Forums</a> <hr width="95%"> <a href="team.html">Our Team</a> <hr width="95%"> <a href="tournaments.html">Tournaments</a> <hr width="95%"> <a href="downloads.html">Downloads</a> <hr width="95%"> <a href="register.html">Register</a> <hr width="95%"> <!--<a href="#">Help</a> <hr width="95%" color="black">--></div> <!--CONTENT--> <div class="content"> <div class="content-header c1"> <h1>What is Blocks?</h1> </div> <p>Welcome to Blocks. Here you can find and download Minecraft Maps and enter into awesome Minecraft Tournaments, oh and IT'S ALL FREE!!!</p> <div class="content-header c1"> <h1>What are the Tournaments?</h1> </div> <p>The tournaments you can enter here are unlike any other! If you enjoy minecraft, then you should sign up for this site. The tournaments could range from crafting something in a specified space to creating a whole map! Check out the <a href="tournaments.html">Tournaments</a> page for more information.</p> <div class="content-header c1"> <h1>When are the Tournaments?</h1> </div> <p>Check out the <a href="tournaments.html">Tournaments</a> page to find out when you can start siging up for tournaments and for a complete list of upcoming tournaments!</p> <div class="content-header c1"> <h1>Worm's Blog</h1> </div> <p>Check <a href="worm.html">Here</a> to see updates and to leave comments!</p> <br><br><br><br><br><br><br><br><br><br><br><br><br> </div> <!--RIGHT SIDEBAR--> <div class="rsbar-signin"> <h2>SIGN IN</h2> <br> <p>Incorrect Username or Password</p> <hr width="95%"> <h2>Why Register?</h2> <p>Registering with us will make you eligible to join our Minecraft Tournaments. You will also be entered into our mailings list and will recieve emails containing information on upcoming maps and tournaments.</p> </div> <!--FOOTER--> <center><div class="footer">©Blocks.netne.net</div></center> </div> </div> </body> </html> <!--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------> <?php } mysql_close($con); ?> |
Christian J |
May 25 2012, 12:37 PM
Post
#2
|
. Group: WDG Moderators Posts: 9,661 Joined: 10-August 06 Member No.: 7 |
CODE $login_user = mysql_query("SELECT username FROM user"); $login_pass = mysql_query("SELECT password FROM user"); The above returns the entire username and password columns in the DB table. You also need to loop through the column rows until you find one that matches the submitted form data. CODE if ('$login_user' === '$user' && '$login_pass' === '$password'); This post has been edited by Christian J: May 26 2012, 01:07 PM |
Christian J |
May 26 2012, 01:05 PM
Post
#3
|
. Group: WDG Moderators Posts: 9,661 Joined: 10-August 06 Member No.: 7 |
The above returns the entire username and password columns in the DB table. You also need to loop through the column rows until you find one that matches the submitted form data. I'm not very experienced with databases, but if the DB table contains lots of rows I guess it's more efficient to search for the submitted form data already in the SQL query? In that case you should sanitize the form data to prevent SQL injections. See also http://php.net/manual/en/function.mysql-re...cape-string.php |
Lo-Fi Version | Time is now: 27th April 2024 - 09:58 PM |