Isset problem ... !

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
User avatar
Skywalker
Forum Contributor
Posts: 117
Joined: Thu Aug 29, 2002 3:33 am
Location: The Netherlands

Isset problem ... !

Post by Skywalker »

I have a small problem. The script must first control if the of the user is fild in. If not the user is send back to the mayne page to fill in his namen.

If the name is set and sended to the cookie, the name must be appear auto.

The problem is, when you are filling in your name, it doesn't make a cookie. But it gose to right page. and doesn't send the people back to fill in ther names. The mayne problem is that the cookie isn't been made.

Here is my litle script.

if (isset($_POST['NewNaam'])) {
$Naam=$_POST['NewNaam'];

if (isset($_COOKIE['Naam'])) {
$Naam =($_COOKIE['Naam']);
echo '' ;
} else {
$cookieset = setcookie('Naam', $NewNaam, time()+43200);
if (!empty($cookieset)) {
$Naam = $NewNaam;
echo '';
} else {
echo 'error - cookie could not be set';
}
}


} else {
echo ("<META HTTP-EQUIV=\"refresh\" content=\"2;URL=index.php\">\n");
}


Thx you all, Skywalker
dusty
Forum Contributor
Posts: 122
Joined: Sun Apr 28, 2002 9:52 pm
Location: Portsmouth, VA

Post by dusty »

Code: Select all

if(isset($_COOKIE&#1111;'Naam'])) {
  $Naam = $_COOKIE&#1111;'Naam'];
} elseif(isset($_POST&#1111;'NewNaam'])) {
  $Naam = $_POST&#1111;'NewNaam'];
  setcookie("Naam", $NewNaam, time()+43200);
} else {
  header("location: index.php");
}
User avatar
Skywalker
Forum Contributor
Posts: 117
Joined: Thu Aug 29, 2002 3:33 am
Location: The Netherlands

Post by Skywalker »

This script doesn't work correctly, it doesn't make eny cookie?
Do I have to replace al of the old script or just a pease?

Tell me.
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

Code: Select all

&lt;?php
if(isset($_COOKIE&#1111;'Naam'])) { 
  $Naam = $_COOKIE&#1111;'Naam']; 
} elseif(isset($_POST&#1111;'NewNaam'])) { 
  $Naam = $_POST&#1111;'Naam']; 
  setcookie("Naam", $Naam, time()+43200); 
} else { 
  header("location: index.php"); 
}
?&gt;
Image Image
Post Reply