K
kevin_zhongguo
Guest
I am trying to set a cookie based on information given through a form. I am trying to save the information that is sent through the form and make it a cookie, to then later call the cookie. If javascript is better to do this, please tell me how because I am don't know much of javascript.
This is what I got so far:
<?php
if (isset($_COOKIE["name1"]) and isset($COOKIE["url1"]))
{
$set1 ="yes";
$name1 = $_COOKIE["name1"];
$url1 = $_COOKIE["url1"];
}else{
}
?>
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Submit</title>
</head>
<body>
<?php
if ($set1 = "yes")
{
echo $name1;
echo $url1;
}else{
}
?>
<br>
<br>
If its working properly, something should show on top of this.
<br>
<br>
<br>
<br>
<form method="POST" action="submitinfo.html">
<p>
Nombre de Website:<br>
<input type="text" name="name1" size="20"><br>
URL:<br>
<input type="text" name="url1" size ="20"</p>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>
And the submitinfo.html is :
<?php
$_POST["name1"]$name1;
$_POST["url1"]=$url1;
if (isset($name1))
{
setcookie("name1",$name1,time()+36000000);
setcookie("url1",$url1,time()+36000000);
}
else
{
echo "This ain't working!";
}
header ("Location: submit.html");
?>
<html>
</html>
I think I didn't explain well what this script if for. The script is for a person to submit the website name, and the url of their favorite websites. So, when they click submit, it makes a cookie with both things, and then in the main page if they are set then I print them in the way I want them to. Does this make sense?
This is what I got so far:
<?php
if (isset($_COOKIE["name1"]) and isset($COOKIE["url1"]))
{
$set1 ="yes";
$name1 = $_COOKIE["name1"];
$url1 = $_COOKIE["url1"];
}else{
}
?>
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Submit</title>
</head>
<body>
<?php
if ($set1 = "yes")
{
echo $name1;
echo $url1;
}else{
}
?>
<br>
<br>
If its working properly, something should show on top of this.
<br>
<br>
<br>
<br>
<form method="POST" action="submitinfo.html">
<p>
Nombre de Website:<br>
<input type="text" name="name1" size="20"><br>
URL:<br>
<input type="text" name="url1" size ="20"</p>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>
And the submitinfo.html is :
<?php
$_POST["name1"]$name1;
$_POST["url1"]=$url1;
if (isset($name1))
{
setcookie("name1",$name1,time()+36000000);
setcookie("url1",$url1,time()+36000000);
}
else
{
echo "This ain't working!";
}
header ("Location: submit.html");
?>
<html>
</html>
I think I didn't explain well what this script if for. The script is for a person to submit the website name, and the url of their favorite websites. So, when they click submit, it makes a cookie with both things, and then in the main page if they are set then I print them in the way I want them to. Does this make sense?