Jump to content

Setting Cookies


havox

Recommended Posts

Well this isn't all about cookies or maybe it is, I'm not to sure. On top of this my script has suddenly broke and stops at check.php

 

I'm also not sure how I should go about checking the cookie to identify the user and how to keep other from viewing the output page(s).

 

 

<html>
<head>
<title>Deadnode.com</title>
   <style type="text/css">
img {
	position:absolute;
	left:300px;
	top:130px;
	z-index:-1; }
form {
	position:absolute;
	left:365px;
	top:248px;
	z-index:0; }
   </style>
</head>
<body>
<img src="iL0bw.png" />

<form method="post" action="check.php">
<center><table>
<tr><td><font face="verdana,arial" size=-1>Username:</td><td><input type="text" size="25" name="user"></td>
<tr><td><font face="verdana,arial" size=-1>Password:</td><td><input type="password" size="25" name="pwd"></td>
<tr><td><font face="verdana,arial" size=-1> </td><td><font face="verdana,arial" size=-1><input type="submit" value="Login"></td></tr>
</table></center>
</form>

</body>
</html>

 

<?php
function check() {

$admin="test";
$pass="test";

if (isset($_POST["user"]) && $_POST["user"] == $admin && isset($_POST["pwd"]) && $_POST["pwd"] == $pass) {
  header('Location: output.php'); 
  setcookie("usr", "test", time()+3600);
else {
  header('Location: index.html'); }

}
?>

 

<?php
require('function.php');

check();

?>

 

<?php
require('check.php');


?>
<html>
<body>

<p>Congrats!</p>

</body>
</html> 

Link to comment
https://forums.phpfreaks.com/topic/219325-setting-cookies/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.