PHP Error?

10 posts Page 1 of 1
Contributors
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1891
Joined: Wed Dec 16, 2009 9:56 pm

PHP Error?
zachman61
I cannot find out why I have an error on line 22.
Code: Select all
	<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 />';
}
?>
Please help.
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
Vikhedgehog
VIP - Donator
VIP - Donator
Posts: 812
Joined: Fri Nov 05, 2010 6:24 pm

Re: PHP Error?
Vikhedgehog
What error are you getting?
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Re: PHP Error?
CodenStuff
I think your missing a } before ?>
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Re: PHP Error?
Codex
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
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1891
Joined: Wed Dec 16, 2009 9:56 pm

Re: PHP Error?
zachman61
Thanks guys, that was it.
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 :)
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Re: PHP Error?
Codex
zachman61 wrote:
Thanks guys, that was it.
But how can I keep the thing from echoing that the user isn't signed in?
Do you want to remove the "Error Signing in.<br />" echo or the "Input username and password" echo ?
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
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1891
Joined: Wed Dec 16, 2009 9:56 pm

Re: PHP Error?
zachman61
Codex wrote:
zachman61 wrote:
Thanks guys, that was it.
But how can I keep the thing from echoing that the user isn't signed in?
Do you want to remove the "Error Signing in.<br />" echo or the "Input username and password" echo ?
I want it to echo the error signing in after the submit is clicked if the details are wrong.
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: PHP Error?
mandai
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
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1891
Joined: Wed Dec 16, 2009 9:56 pm

Re: PHP Error?
zachman61
mandai wrote:
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
At the moment as soon as the page loads "failed to sign in." I don't want that to happen.
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: PHP Error?
mandai
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
Return to “Help & Support”