Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Having a wee cookie problem
Old 04-26-2005, 02:38 PM Having a wee cookie problem - Revised
merlin's Avatar
Skilled Talker

Posts: 52
Trades: 0
After some careful consideration I have decided to convert from sessions to cookies. I am however having a bit of trouble just getting started. I have a password page that should accept only one password, set the cookie and move on to the next page. But instead it just sits there doing nothing or it just loops back to the password page again. Can some please have a look at my code to see where I have made my error?

Thanks,
Code I'm using to check if the cookie is there...
PHP Code:
<?php
ob_start
();
if (!isset(
$_COOKIE["nccpass1"])){
header("location: password/password_cs.php");
}
?>
Code I'm using if the cookie is not there.....

PHP Code:
<?php
ob_start
();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>NCC Security</title>
<?php
include ('..\includes\cssinclude.php');
include (
'..\includes\meta.php');
?>
</head>
<body>
<div id="content">

<?php
include ('..\includes\outline.php');
?>
<p>
<div align="center">
<h2 class="style1"><font color="#FF0000">PASSWORD PROTECTED AREA </font> </h2>
<p class="style1"><img src="../images/lock.jpg" width="68" height="81"> <img src="../images/lock.jpg" width="68" height="81"> <img src="../images/lock.jpg" width="68" height="81"> <img src="../images/lock.jpg" width="68" height="81"></p>
<h3><strong>You must enter a password to continue. </strong>
</h3>
</p>
<form method="post" action="password_cs.php">
<div align="center">
<center>
<table border="0" cellpadding="5" cellspacing="0">
<tr>
<td>
</td>
<td><input name="password" type="password" size="30" /></td>
</tr>
</table>
</center>
</div>
<p align="center">
<input type="submit" name="submit" value="Enter my password" class="button_colour" /></p>
</form>
<?php 
    
    
if (isset($_POST['submit'])) {
        if (
$_POST['password'] == ("123456")) {
        
setcookie("nccpass1"$passwordtime()+600);
        
header('location: ../General.php');
        exit();
    } else { 
        include(
'error_p.htm');
    }
}
?>
</body>
</div>
</html>

Last edited by merlin; 04-26-2005 at 05:06 PM..
merlin is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-26-2005, 05:09 PM
merlin's Avatar
Skilled Talker

Posts: 52
Trades: 0
I have revised my code with what is above
merlin is offline
Reply With Quote
View Public Profile
 
Old 04-26-2005, 05:25 PM
merlin's Avatar
Skilled Talker

Posts: 52
Trades: 0
Never mind, I got it.
merlin is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Having a wee cookie problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11022 seconds with 12 queries