Cookie Implementation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aking1987
Forum Newbie
Posts: 2
Joined: Wed May 19, 2004 9:25 am

Cookie Implementation

Post by aking1987 »

How can i implement a cookie to by-pass the login for this script... (im a right beginner so detailed explanation wud b helpful)

Code: Select all

<html>

<head>
<title>password protection test</title>
</head>

<body>
<?php

// Define your username and password
$username = "user";
$password = "password";

if ($_POST&#1111;'txtUsername'] != $username || $_POST&#1111;'txtPassword'] != $password) &#123;

?>
<p>
<b>Login</b>
</p>
<form name="form" method="post" action="<?php echo $_SERVER&#1111;'PHP_SELF']; ?>">
<div align="center">
<center>
<table border="0" cellpadding="5" cellspacing="0">
<tr>
<td><label for="txtUsername">Username</label>
</td>
<td><input type="text" title="Enter your Username" name="txtUsername" /></td>
</tr>
<tr>
<td><label for="txtpassword">Password</label>
</td>
<td><input type="password" title="Enter your password" name="txtPassword" /></td>
</tr>
</table>
</center>
</div>
<p align="center"><input type="submit" name="Submit" value="Login" /></p>
</form>

<?php
&#125;
else &#123;
?>

<p>This is the protected page. Place your content here.</p>

<?php
&#125;
?> 

</body>

</html>
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Maybe this thread is helpful to you: viewtopic.php?t=11417
aking1987
Forum Newbie
Posts: 2
Joined: Wed May 19, 2004 9:25 am

Post by aking1987 »

im sorry... i have no idea how to do this

i have practically ne experience with stuff like this

:?: :?:
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Post Reply