Hi all, Probably going to be something simple i am doing wrong here so your help is much appreciated. I trying to redirect a user to a page when they log in, the if statement used is this. if (isset($_POST["username"])) { if (($_POST["username"]=="myUser") && ($_POST["password"]=="myPassword")) // VALID LOGIN { $_SESSION["loggedIn"]=true; echo "<a href="test.php">Back to Homepage</a>"; } else // INVALID LOGIN { echo "wrong username and password - click back to try again"; } } else // NO USERNAME ENTERED { echo "username is blank - click back to try again"; } ?> The part which is bold and underlined is the problem. I keep getting syntax errors, all i want to do is say if login is correct then give them a href link back to the main page. The file is called authenticate.php, is it a problem due to the fact it is a .php extention as the HTML part doesnt seem to being recongised. Please help. Thanks
$page = "users/$user.html"; // replace with you page header("Location:$page"); or, you could use a echo "<body onload=\"window.location='$page'\">"; or echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0; URL=$page\">"; or of course you could include("$page"); ps I got from here
Change echo "<a href="test.php">Back to Homepage</a>"; to echo "<a href=\"test.php\">Back to Homepage</a>";
EDIT: Too late... if (isset($_POST["username"])) { if (($_POST["username"]=="myUser") && ($_POST["password"]=="myPassword")) // VALID LOGIN { $_SESSION["loggedIn"]=true; echo "<a href=\"test.php\">Back to Homepage</a>"; } else // INVALID LOGIN { echo "wrong username and password - click back to try again"; } } else // NO USERNAME ENTERED { echo "username is blank - click back to try again"; } PHP: