PHP Error?
10 posts
Page 1 of 1
I cannot find out why I have an error on line 22.
Code: Select all
Please help. <head><title>Login to Continue</title>
<form method="post" action="<?php echo $PHP_SELF;?>">
Username: <input type="text" name="username"><br />
Password: <input type="password" name="password" /><br />
<input type="submit" value="submit" name="submit">
</form>
<?php
$user = 'u123';
$pass = 'p123';
$signedin = False;
$iuser = $_POST["username"];
$ipass = $_POST["password"];
/*------------*/
if ($user == null || $pass == null) {
echo 'Input username and password';
} else {
if ($user == $iuser || $pass == $ipass) {
echo 'Successfully Signed in.<br />';
} else {
echo 'Error Signing in.<br />';
}
?>
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that
I think your missing a } before ?>
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
You forgot to close the { like Craig said. Add a } before ?>
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
Thanks guys, that was it.
But how can I keep the thing from echoing that the user isn't signed in?
But how can I keep the thing from echoing that the user isn't signed in?
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that
zachman61 wrote:Thanks guys, that was it.Do you want to remove the "Error Signing in.<br />" echo or the "Input username and password" echo ?
But how can I keep the thing from echoing that the user isn't signed in?
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
Codex wrote:I want it to echo the error signing in after the submit is clicked if the details are wrong.zachman61 wrote:Thanks guys, that was it.Do you want to remove the "Error Signing in.<br />" echo or the "Input username and password" echo ?
But how can I keep the thing from echoing that the user isn't signed in?
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that
If you need to check if both the user and pass are correct then you would want to use the AND operator.
Code: Select all
if ($user == $iuser && $pass == $ipass) { //only show success if both are correct
mandai wrote:If you need to check if both the user and pass are correct then you would want to use the AND operator.At the moment as soon as the page loads "failed to sign in." I don't want that to happen.Code: Select allif ($user == $iuser && $pass == $ipass) { //only show success if both are correct
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that
If you check to see if the iuser/ipass variables are null then you can change or remove that message.
Code: Select all
/*------------*/
if ($iuser == null || $ipass == null) {
10 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023