After doing a search on php.net and these forums i have tried to set some cookies, i have a form which sends a name and email address toa page which adds it info to a databse then sets a cookies so when hey go to another page or come back in a wek or month it remembers that they have signed up to the mailinglist and prints there name/email instead of the form.
mailiglist.php //the form sends the data to this page
[code=php]
<?
include(‘library/top.php’);
include(‘library/connect.php’);
print “<p class=’list’><div align=’center’>Mailing list successfully joined</div></p>”;
$name = $_POST[‘name’];
$email = $_POST[’email’];
setcookie(“$cookie[name]”, $name);
setcookie(“$cookie[email]”, $email);
$addmailinglist = “INSERT INTO mailinglist(name, email)
VALUES(‘$name’,’$email’)”;
mysql_query($addmailinglist);
include(‘library/footer.php’);
?>
and the header included in the top of every page
[code=php]
<?php
//check to see if cookies are set, if so prints the name and email. else sets the form
if (isset($_COOKIE[‘cookie’])) {
foreach ($_COOKIE[‘cookie’] as $name => $value) {
echo ” Welcome $name : $value <br />n”;
}
}else{
//print the sign up form.
?>
<p class=”list”>
<div align=”center”>Join the mailing list to know when new photos and messages have been added!!!<br><br>
<form action=”mailinglist.php” method=”post” name=”joinmailinglist”>
Name:<input type=”text” name=”name” size=”25″> Email:<input type=”text” name=”email” size=”25″>
<input type=”submit” name=”join” value=”Join”>
</form>
</div>
</p>
<?php //end the form and the cookie code.
}
?>
Thanks Alot, i really just cant get cookies.