APD1993 Posted March 3, 2012 Share Posted March 3, 2012 I have a PHP script that has hyperlinks on that allow for the user to go to different pages, and I have managed to mainly get the hyperlinks to be button based ones, except on one of the pages, an error message appears, reading: Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\congrats.php on line 58 However, I do not see what the problem is. My congrats.php script is: <!--Here, I am creating a header and title (for the webpage) with the use of the <head> and <title> HTML tags. The title given to the webpage is Login Details. I then am using the </title> and </head> HTML tags in order to stop the creation of the title and header of the webpage--> <head><title>Login Details</title> <link rel="stylesheet" type="text/css" a href="/rcm/stylesheet.css"> </head> <!--Here, I am starting a PHP script--> <?php //Here, I am creating two variables called $loginname and $loginpassword that are being assigned the values of what is entered into and posted from the text box called name and the password box called pass in the loginform.php webpage $loginname=$_POST['name']; $loginpassword=$_POST['pass']; //Here, an IF statement is being created and the empty keyword is being used to state that if the value assigned to the $loginname and the $loginpassword variables is empty (i.e. the 'name' text box and the 'pass' password box on the loginform.php page are both left empty), then the echo keyword is being used to help write a string to inform the user that they have not entered in a username or a password and a link back to the loginform.php page is provided to them to click on and the exit function with no arguments in the parameters is being used to exit the script if (empty($loginname) && empty($loginpassword)) { echo "You have not entered in a username or password"; echo"<br><a href=\"loginform.php\">Click here to try to log in again</a>"; exit(); } //Here, an elseif branch of the IF statement is being created and the empty keyword is being used to state that if the value assigned to the $loginname variable is empty (i.e. the 'name' text box on the loginform.php page is left empty), then the echo keyword is being used to help write a string to inform the user that they have not entered in a username and a link back to the loginform.php page is provided to them to click on and the exit function with no arguments in the parameters is being used to exit the script elseif (empty($loginname)) { echo "You have not entered in a username"; echo "<br><a href=\"loginform.php\">Click here to try to log in again</a>"; exit(); } //Here, an elseif branch of the IF statement is being created and the empty keyword is being used to state that if the value assigned to the $loginpassword variable is empty (i.e. the 'pass' password box on the loginform.php page is left empty), then the echo keyword is being used to help write a string to inform the user that they have not entered in a password and a link back to the loginform.php page is provided to them to click on and the exit function with no arguments in the parameters is being used to exit the script elseif(empty($loginpassword)) { echo "You have not entered in a password"; echo"<br><a href=\"loginform.php\">Click here to try to log in again</a>"; exit(); } //Here, an elseif branch to the IF statement is being created and the empty keyword is being used to state that if the value assigned to the $loginname and the $loginpassword variables is incorrect (i.e. the 'name' text box and the 'pass' password box on the loginform.php page are both left incorrectly filled in), then the echo keyword is being used to help write a string to inform the user that they have not entered in a correct username and password and a link back to the loginform.php page is provided to them to click on and the exit function with no arguments in the parameters is being used to exit the script elseif (($loginname != "mrjones")&& ($loginpassword != "January")) { echo "You have entered an incorrect username and password"; echo"<br><a href=\"loginform.php\">Click here to try to log in again</a>"; exit(); } //Here, an elseif branch to the IF statement is being created and the empty keyword is being used to state that if the value assigned to the $loginname variable is incorrect and the value assigned to the $loginpassword variable is ccorrect (i.e. the 'name' text box on the loginform.php page was filled in incorrectly and the 'pass' password box on the loginform.php page was filled in correctly), then the echo keyword is being used to help write a string to inform the user that they have not entered in a correct username and a link back to the loginform.php page is provided to them to click on and the exit function with no arguments in the parameters is being used to exit the script else if (($loginname !="mrjones") && ($loginpassword == "January")) { echo "You have entered in an incorrect username"; echo"<br><a href=\"loginform.php\">Click here to try to log in again</a>"; exit(); } //Here, an elseif branch to the IF statement is being created and the empty keyword is being used to state that if the value assigned to the $loginname variable is incorrect and the value assigned to the $loginpassword variable is ccorrect (i.e. the 'name' text box on the loginform.php page was filled in correctly and the 'pass' password box on the loginform.php page was filled in incorrectly), then the echo keyword is being used to help write a string to inform the user that they have not entered in a correct password and a link back to the loginform.php page is provided to them to click on and the exit function with no arguments in the parameters is being used to exit the script elseif (($loginname =="mrjones") && ($loginpassword != "January")) { echo "You have entered in an incorrect password"; echo"<br><a href=\"loginform.php\">Click here to try to log in again</a>"; exit(); } //Here, an else branch to the IF statement is being created so as to essentially state that if all of the other branches of the IF statement above are passed through, then it means that the user managed to successfully log on and the echo keyword is being used to help write a string congratulating the user that they managed to log in and a link is provided for them to log off and go back to the loginform.php page and the exit function with no arguments in the parameters is being used to exit the script else { echo "<h1>Log In Successful!</h1>"; <form action="amendfile2.php" method="post"> <input type="submit" value="Amend to file"> </form> <form action="viewfile3.php" method="post"> <input type="submit" value="View Web Blog"> </form> <form action="loginform.php" method="post"> <input type="submit" value="Click here to go to the Log In Screen"> </form> } //Here, the PHP script is being ended ?> Any help is appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/258191-how-can-i-add-button-based-hyperlinks-to-this-particular-php-script/ Share on other sites More sharing options...
Pikachu2000 Posted March 3, 2012 Share Posted March 3, 2012 You've put an html comment inside of a <?php code block. Quote Link to comment https://forums.phpfreaks.com/topic/258191-how-can-i-add-button-based-hyperlinks-to-this-particular-php-script/#findComment-1323506 Share on other sites More sharing options...
APD1993 Posted March 3, 2012 Author Share Posted March 3, 2012 You've put an html comment inside of a <?php code block. So is there a way of fixing this issue then? Quote Link to comment https://forums.phpfreaks.com/topic/258191-how-can-i-add-button-based-hyperlinks-to-this-particular-php-script/#findComment-1323524 Share on other sites More sharing options...
AJLX Posted March 3, 2012 Share Posted March 3, 2012 echo"<br><a href='loginform.php'>Click here to try to log in again</a>"; Works for me Quote Link to comment https://forums.phpfreaks.com/topic/258191-how-can-i-add-button-based-hyperlinks-to-this-particular-php-script/#findComment-1323526 Share on other sites More sharing options...
Pikachu2000 Posted March 3, 2012 Share Posted March 3, 2012 Yeah, I was wrong about the html comment; I inadvertently pasted your code into my editor after an opening <?php tag, but further down in the script, you have html outside of an echo. Same problem, different location. For larger blocks of stuff being echoed, you might prefer to use HEREDOC syntax. Just a thought. Quote Link to comment https://forums.phpfreaks.com/topic/258191-how-can-i-add-button-based-hyperlinks-to-this-particular-php-script/#findComment-1323531 Share on other sites More sharing options...
AJLX Posted March 3, 2012 Share Posted March 3, 2012 replace Line 55 through 70 with this: else { echo "<h1>Log In Successful!</h1> <form action='amendfile2.php' method='post'> <input type='submit' value='Amend to file'> </form> <form action='viewfile3.php' method='post'> <input type='submit' value='View Web Blog'> </form> <form action='loginform.php' method='post'> <input type='submit' value='Click here to go to the Log In Screen'> </form>"; } //Here, the PHP script is being ended ?> Any better? Quote Link to comment https://forums.phpfreaks.com/topic/258191-how-can-i-add-button-based-hyperlinks-to-this-particular-php-script/#findComment-1323532 Share on other sites More sharing options...
APD1993 Posted March 3, 2012 Author Share Posted March 3, 2012 replace Line 55 through 70 with this: else { echo "<h1>Log In Successful!</h1> <form action='amendfile2.php' method='post'> <input type='submit' value='Amend to file'> </form> <form action='viewfile3.php' method='post'> <input type='submit' value='View Web Blog'> </form> <form action='loginform.php' method='post'> <input type='submit' value='Click here to go to the Log In Screen'> </form>"; } //Here, the PHP script is being ended ?> Any better? That seems to have done the job! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/258191-how-can-i-add-button-based-hyperlinks-to-this-particular-php-script/#findComment-1323533 Share on other sites More sharing options...
AJLX Posted March 3, 2012 Share Posted March 3, 2012 If you use an echo statement, you can't use " inside the statement. For example this won't work: echo " <img src="images/something.jpg" width="100px" height="100px">"; So the answer is to use the ' symbol instead. This code would work: echo " <img src='images/something.jpg' width='100px' height='100px'>"; Hope this helps Quote Link to comment https://forums.phpfreaks.com/topic/258191-how-can-i-add-button-based-hyperlinks-to-this-particular-php-script/#findComment-1323557 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.