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!

Simple Authentication Script ? 1

Status
Not open for further replies.

maverick

MIS
Apr 21, 1999
193
US
Don't anyone blow a gasket !
I'm learning, and I know my scripts are old !
but just the same, they are teaching me a lot !

I'm having a problem making this simple script work !

<?php
if(!isset($name)&&!isset($password))
{
//Visitor needs to enter a name and password
?>
<center>
<h1>Please Log In</h1>
This page is secret.
<form method="post" action="secret.php">
<table border = 1 width="250">
<tr>
<th width="90" align="center"> Username </th>
<td align="center">
<input type="text" name="name"> </td>
</tr>
<tr>
<th> Password </th>
<td align="center">
<input type="password" name="password">
</td>
</tr>
<tr>
<td colspan="2" align="center" height="40">
<input type="submit" value="Log In">
</td>
</tr>
</form>
</center>
<?php
}
else if($name=="user"&&$password=="pass")
{
// visitor's name and password combination are correct
echo "<h1>Here it is!</h1>";
echo "I bet you are glad you can see this secret page.";
}
else
{
// visitor's name and password combination are not correct
echo "<h1>Go Away!</h1>";
echo "You are not authorized to view this resource.";
}
?>

Any ideas ?

tia :)

&quot;Hacker by Heart&quot;
saenzcorp@hotpop.com
 
what is the error/misbehaviour ur getting?

are the register globals on or off..

if they are OFF (by default they are OFF), use $_POST["name"] and $_POST["password"] instead of $name and $password.



--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
thanks I'll try that !
right now !

&quot;Hacker by Heart&quot;
saenzcorp@hotpop.com
 
I'm not exactly sure where you want me toput the changes ????

&quot;Hacker by Heart&quot;
saenzcorp@hotpop.com
 
replace this
if(!isset($name)&&!isset($password))
with
if(!isset($_POST["name"]) && !isset($_POST["password]))

replace this
else if($name=="user"&&$password=="pass")
with
else if($_POST["name"] == "user"&& $_POST["password"] == "pass")


hope that will help



--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
That did it !
thank you !


--------------------------------------
&quot;Hacker by Heart&quot;
saenzcorp@hotpop.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top