I want my website to remember people's email when they post on my website.

<form method="post" action="formposting.php">
<input type="text" name= "title" size="22">
<input type="text" name= "email" size="22">
<?php 
if(!$_COOKIE['cookname']) {
echo "<input type=\"checkbox\" name=\"remember\" id=\"remember\" /> Remember me on this computer"; 
} 

else{
echo $email; 
echo "Forget Me{delete cookie//help here too}";
} 
?>
</div>
<input type="submit" value="post"/>
</form>


if (isset($_POST['remember'])) {
parse_str($_COOKIE[$cookname]);
$number_of_days = 100000 ;
$date_of_expiry = time() + 60 * 60 * 24 * $number_of_days ;
setcookie( "cookname", "anonymous", $date_of_expiry, "/", "url.com" );  
}

What i don't know is how display the user's email, if user wants to post again at a later date, if it was checked and if it wasn't checked show the input type for email and if they click forget me it should forget them and show input type for email

Recommended Answers

All 2 Replies

HI,

first of all, it's not a good idea to store the mail plain, better generate a crypt key, and same the email on your side with the key.

Anyway it would be like this:

<form method="post" action="formposting.php">
<input type="text" name= "title" size="22">
<input type="text" name= "email" size="22">
<?php 

if(!$_COOKIE['cookname']) {

 echo "<input type=\"checkbox\" name=\"remember\" id=\"remember\" value="<?php if($_COOKIE[$cookname]) print $_COOKIE[$cookname];  ?>"/> Remember me on this computer"; 
} 

else{
echo $email; 
echo "Forget Me{delete cookie//help here too}";
} 
?>
</div>
<input type="submit" value="post"/>
</form>


if (isset($_POST['remember'])) {
	parse_str($_COOKIE[$cookname]);
	$number_of_days = 100000 ;
	$date_of_expiry = time() + 60 * 60 * 24 * $number_of_days ;
	setcookie( "cookname", $_POST['remember'], $date_of_expiry, "/", "url.com" );  
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.