Jump to content

[SOLVED] Mang the change from sessions to cookies


almightyegg

Recommended Posts

I changed this whole page today and I am currently streaming through all pages making them all cookies rather than sessions, but for some reason this page won't work:

<?
include 'db.php'; // Connect to DB
$email = $_COOKIE['email']; 
$password = $_COOKIE['password']; 
if((!$email) || (!$password)){ 
echo "Please enter ALL of the information! <br />"; 
include '/index.php'; 
exit(); 
} 
$sql = mysql_query("SELECT * FROM users WHERE email='$email' AND password='$password' AND activated='1'"); 
$mem = mysql_fetch_array($sql);
$link = mysql_query("SELECT * FROM links") or die(mysql_error());
$qlink = mysql_fetch_array($link);

$que = mysql_query("SELECT * FROM quests") or die(mysql_error());
$quest = mysql_fetch_array($que);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="default.css"> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Account Settings</title>
</head>

<body bgcolor=black>
<center>
<?
include 'links.php';
?>
</center>
<table border=0 width=100% cellpadding=15>
<td width=150 valign=top>
<?
include 'panel.php';
?>
</td>
<td valign=top>
<?
if(!$step){
?>
General Settings<br>
<a href="<? echo "$_SERVER['PHP_SELF']?step=1"; ?>">Webspace Settings</a><br>
<a href="<? echo "$_SERVER['PHP_SELF']?step=2"; ?>">Message Board Settings</a><br>
<a href="<? echo "$_SERVER['PHP_SELF']?step=3"; ?>">Account Attributes</a>
<?
}elseif($step == "1"){
?>
<a href="<? echo "$_SERVER['PHP_SELF']?step=0"; ?>">General Settings</a><br>
Webspace Settings<br>
<a href="<? echo "$_SERVER['PHP_SELF']?step=2"; ?>">Message Board Settings</a><br>
<a href="<? echo "$_SERVER['PHP_SELF']?step=3"; ?>">Account Attributes</a>
<?
}elseif($step == "2"){
?>
<a href="<? echo "$_SERVER['PHP_SELF']?step=0"; ?>">General Settings</a><br>
<a href="<? echo "$_SERVER['PHP_SELF']?step=1"; ?>">Webspace Settings</a><br>
Message Board Settings<br>
<a href="<? echo "$_SERVER['PHP_SELF']?step=3"; ?>">Account Attributes</a>
<?
}elseif($step == "3"){
?>
<a href="<? echo "$_SERVER['PHP_SELF']?step=0"; ?>">General Settings</a><br>
<a href="<? echo "$_SERVER['PHP_SELF']?step=1"; ?>">Webspace Settings</a><br>
<a href="<? echo "$_SERVER['PHP_SELF']?step=2"; ?>">Message Board Settings</a><br>
Account Attributes
<?
}


</td>
</table>
<center>
<?
include 'links.php';
?>
</center>
</body>
</html>

 

 

It stops here:

if((!$email) || (!$password)){

echo "Please enter ALL of the information! <br />";

include '/index.php';

exit();

because it brings up that error page and says Please enter ALL of the information! :(

Link to comment
Share on other sites

at the bottom of the page

<?

}

 

 

</td>

</table>

<center>

<?

include 'links.php';

?>

</center>

</body>

</html>

you open a tag, and dont close it..

 

Even with it closed it shows same problems...

 

 

and if you havent already realised, exit(); or die(); both terminate the rest of the page

It is meant to, if there is an error, the page they are tryin to access is members only so it terminates that page and brngs up the home page...

Link to comment
Share on other sites

I'll show you code from pages that work and page(s) that don't..

Pages that do:

<?
include 'db.php';
$email = $_COOKIE['email']; 
$password = $_COOKIE['password']; 
if((!$email) || (!$password)){ 
echo "Please enter ALL of the information! <br />"; 
include 'index.php'; 
exit(); 
} 

 

Pages that don't:

<?
include 'db.php'; // Connect to DB
$email = $_COOKIE['email']; 
$password = $_COOKIE['password']; 
if((!$email) || (!$password)){
echo "Please enter ALL of the information! <br />"; 
include '/index.php'; 
exit(); 
}

Link to comment
Share on other sites

<?php

include 'db.php';

$email = $_COOKIE['email'];

$password = $_COOKIE['password'];

if((!$email) || (!$password)){

echo "Please enter ALL of the information! <br />";

header("location: index.php");

}

?>

 

try using a header, then see what happens

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.