Dench Posted February 18, 2008 Share Posted February 18, 2008 <? require("db.inc.php"); if(! empty($_POST['UserName']) && ! empty($_POST['Password'])) { $UserName = mysql_real_escape_string($_POST['UserName']); $PassWord = mysql_real_escape_string($_POST['Password']); $sql = "SELECT UserName FROM login_table WHERE UserName = '{$UserName}' AND Password = '{$Password}'"; $query = mysql_query($sql); if(mysql_num_rows($query) == 1) { echo "You have been sucessfully logged in! <br><br> <a href="result.php">Continue...</a>"; } else { echo "Your login failed. =( <br><br> <a href="index.html">Go back...</a>"; } } else { die("You did not enter a name and email address"); } ?> Now, i implemented this in easyPHP, and tested the login and i receive the following output: Continue... "; } else { echo "Your login failed. =( Go back..."; } } else { die("You did not enter a name and email address"); } ?> I am confused as to why part of my code has simply been regurgitated back to me, i have played with the syntax but cannot solve this problem please help!! Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted February 18, 2008 Share Posted February 18, 2008 Your code is using short open tags - <? Use the full <?php opening tag. Quote Link to comment Share on other sites More sharing options...
Dench Posted February 18, 2008 Author Share Posted February 18, 2008 I have tried this but receive: Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in C:\Program Files\EasyPHP 2.0b1\www\OurDatabase\login.php on line 14 instead, would it be easier to work around this error?? Quote Link to comment Share on other sites More sharing options...
rlindauer Posted February 18, 2008 Share Posted February 18, 2008 <?php require("db.inc.php"); if(! empty($_POST['UserName']) && ! empty($_POST['Password'])) { $UserName = mysql_real_escape_string($_POST['UserName']); $PassWord = mysql_real_escape_string($_POST['Password']); $sql = "SELECT UserName FROM login_table WHERE UserName = '{$UserName}' AND Password = '{$Password}'"; $query = mysql_query($sql); if(mysql_num_rows($query) == 1) { echo "You have been sucessfully logged in! <br><br> <a href="result.php">Continue...</a>"; } else { echo "Your login failed. =( <br><br> <a href="index.html">Go back...</a>"; } } else { die("You did not enter a name and email address"); } ?> You have syntax errors. You have to escape your quotes in your echo statements. Quote Link to comment Share on other sites More sharing options...
vicodin Posted February 19, 2008 Share Posted February 19, 2008 <?php require("db.inc.php"); if(! empty($_POST['UserName']) && ! empty($_POST['Password'])) { $UserName = mysql_real_escape_string($_POST['UserName']); $PassWord = mysql_real_escape_string($_POST['Password']); $sql = "SELECT UserName FROM login_table WHERE UserName = '{$UserName}' AND Password = '{$Password}'"; $query = mysql_query($sql); if(mysql_num_rows($query) == 1) { echo "You have been sucessfully logged in! <br><br> <a href="result.php">Continue...</a>"; } else { echo "Your login failed. =( <br><br> <a href="index.html">Go back...</a>"; } } else { die("You did not enter a name and email address"); } ?> Change it to: <?php require("db.inc.php"); if(! empty($_POST['UserName']) && ! empty($_POST['Password'])) { $UserName = mysql_real_escape_string($_POST['UserName']); $PassWord = mysql_real_escape_string($_POST['Password']); $sql = "SELECT UserName FROM login_table WHERE UserName = '{$UserName}' AND Password = '{$Password}'"; $query = mysql_query($sql); if(mysql_num_rows($query) == 1) { echo 'You have been sucessfully logged in! <br><br> <a href="result.php">Continue...</a>'; } else { echo 'Your login failed. =( <br><br> <a href="index.html">Go back...</a>'; } } else { die("You did not enter a name and email address"); } ?> You cant have " inside of a " ... You need to put a ' so it doesnt try to parse the inside " Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.