go to other page if password is correct
Posted: Sat Nov 22, 2008 11:08 am
Hi all,
I have the following code..the username and password works fine but i want the script to go to another webpage if the username and password is enetered correctly.
how do i code the if statement??
I have the following code..the username and password works fine but i want the script to go to another webpage if the username and password is enetered correctly.
how do i code the if statement??
Code: Select all
<?php
$username = "someuser";
$password = "somepassword";
if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {
?>
<h1>Login</h1>
<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<p><label for="txtUsername">Username:</label>
<br /><input type="text" title="Enter your Username" name="txtUsername" /></p>
<p><label for="txtpassword">Password:</label>
<br /><input type="password" title="Enter your password" name="txtPassword" /></p>
<p><input type="submit" name="Submit" value="Login" /></p>
</form>
<?php
}
else {
?>
<p>This is the protected page. Your private content goes here.</p>
<?php
}
?>