Question
Simple login page question
I'm trying to create a simple login using a form and php and
am having
difficulty in troubleshooting - if someone could give me a little help,
I would greatly appreciate it.
Here is the code:
<?php
$error = FALSE;
if (isset($_POST['client_password']) && isset($_POST['client_username'])) {
if (($_POST['client_password'] == 'blah') &&
($_POST['client_username'] == 'blahblah')) {
header("Location=
http://homepage.mac.com/companyname/FileSharing44.html");
exit();
}
else {
$error = "<h2>You have entered an incorrect password/username.
Please try again.</h2>";
}
}
?>
(and in the document body)
<?php echo $error?$error:''; ?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form1
" id="form1">
<label for="client_name">Username<span class="required">*</span></label>
<input name="client_name" type="text" size="20" maxlength="50">
<label for="client_password">Password<span
class="required">*</span></label>
<input name="client_password" type="text" id="client_password"
size="20" maxlength="20">
<label for="send"></label>
<input class="login" type="submit" name="send" id="send" value="Log
In">
</form>
In testing this page in the browser:
1. When I enter the correct username and password, it just drops me back
into the login page.
2. When I enter the incorrect username and password, it drops me back
into the login page without the error message.
Thanks in advance.
difficulty in troubleshooting - if someone could give me a little help,
I would greatly appreciate it.
Here is the code:
<?php
$error = FALSE;
if (isset($_POST['client_password']) && isset($_POST['client_username'])) {
if (($_POST['client_password'] == 'blah') &&
($_POST['client_username'] == 'blahblah')) {
header("Location=
http://homepage.mac.com/companyname/FileSharing44.html");
exit();
}
else {
$error = "<h2>You have entered an incorrect password/username.
Please try again.</h2>";
}
}
?>
(and in the document body)
<?php echo $error?$error:''; ?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form1
" id="form1">
<label for="client_name">Username<span class="required">*</span></label>
<input name="client_name" type="text" size="20" maxlength="50">
<label for="client_password">Password<span
class="required">*</span></label>
<input name="client_password" type="text" id="client_password"
size="20" maxlength="20">
<label for="send"></label>
<input class="login" type="submit" name="send" id="send" value="Log
In">
</form>
In testing this page in the browser:
1. When I enter the correct username and password, it just drops me back
into the login page.
2. When I enter the incorrect username and password, it drops me back
into the login page without the error message.
Thanks in advance.
