Jump to content

How can I add button based hyperlinks to this particular PHP script?


APD1993

Recommended Posts

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! :)

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

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 :D

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.