Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with script 1

Status
Not open for further replies.

csniffer

Programmer
Apr 30, 2003
161
GB
Hi all, I am developing a script to handle logins, at the moment I have the password and username in in the script but when I get this working I will import the pass & username from a database or file but at the minute the script doesn’t work can anybody see the problem. This script runs first and is called login.php
Code:
 <?php
$PageTitle = &quot;Login Please&quot;;
require(&quot;header.php&quot;);

if($message == &quot;Invalid&quot;) {
print(&quot;<B><CENTER><FONT COLOR=RED>The Username and password do not match please try again!</FONT>
</CENTER></B>\n&quot;);
}

print(&quot;<FORM ACTION=\&quot;handleLogin.php\&quot; METHOD=POST>\n&quot;);
print(&quot;Username: <INPUT TYPE=TEXT NAME=UserName><BR>\n&quot;);
print(&quot;Password: <INPUT TYPE=PASSWORD NAME=Password><BR>\n&quot;);
print(&quot;<INPUT TYPE=SUBMIT NAME=SUBMIT VALUE=\&quot;Submit!\&quot;>\n&quot;);
require(&quot;footer.php&quot;);
?>

and then calls this one handleLogin.php.

Code:
<? php
if(($UserName == &quot;tony&quot;) && ($Password == &quot;tony&quot;)) {
header(&quot;Location: index.php?UserName=$UserName&quot;); 
exit;
} else {
header(&quot;Location: login.php?message=Invalid&quot;);
exit;
}
?>

thx in advance


To err is human, to completely mess up takes a computer.
 
I going to assume you are running php 4.xx and you have &quot;register-global off&quot; in your php config. In this case, the problem is the way as you are getting the vars in the file handleLogin.php....

Use:

if(($_POST[&quot;UserName&quot;]== &quot;tony&quot;) && ($_POST[&quot;Password&quot;] == &quot;tony&quot;))

instead if(($UserName == &quot;tony&quot;) && ($Password == &quot;tony&quot;)).

Hope this help you.

Cheers.
 
I going to assume you are running php 4.xx and you have &quot;register-global off&quot; in your php config. In this case, the problem is the way as you are getting the vars in the file handleLogin.php....

Use:

if(($_POST[&quot;UserName&quot;]== &quot;tony&quot;) && ($_POST[&quot;Password&quot;] == &quot;tony&quot;))

instead of:

if(($UserName == &quot;tony&quot;) && ($Password == &quot;tony&quot;)).

Hope this help you.

Cheers.
 
Ok tried that but it is still loading the second page as apposed to just running the script. Register_globals is off and I am using php4xx on Apache, any help on this would be helpful and thx 4 ur replies

To err is human, to completely mess up takes a computer.
 
ok thx 4 ur help but the prob was in the second script there was a space between <? php instead of <?php (only 2 days to find that). derrr.. thx all.

To err is human, to completely mess up takes a computer.
 
btw, you don't need the &quot;Exit;&quot; lines, the header line makes it leave the page before it gets there anyway.
 
'O' right i will remove them thx

To err is human, to completely mess up takes a computer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top