SESSION & <FORM>
| From: | jtjohnston | Date: | Fri, 16 Nov 2001 05:04:43 +0000 |
| Subject: | SESSION & <FORM> | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-74816@lists.php.net to get a copy of this message | ||
HTH. I have solved the problem with this code:
<?php
session_name("TESTpostcard");
session_start();
session_register("name");
if (isset($HTTP_POST_VARS["name"])) //<--------- USE THIS
$name = $HTTP_POST_VARS["name"]; //<-------- HERE
<?php
if($submit=="Submit")
{
echo"<FORM ACTION=\"$SCRIPT_NAME\" METHOD=\"POST\">
<INPUT TYPE=\"text\" NAME=\"name\" value=\"$name\">
<INPUT TYPE=submit name=\"Send\">
<center><img src=\"$SCRIPT_NAME?submit=Display\"></center>
</FORM>
";
}
elseif($submit=="Send")
{
echo"<FORM ACTION=\"$SCRIPT_NAME\" METHOD=\"POST\">
<INPUT TYPE=\"text\" NAME=\"name\" value=\"$name\">
<center><img src=\"$SCRIPT_NAME?submit=Display\"></center>
</FORM>
";
}
elseif($submit=="Display")
{
if($name)
{
header("Content-type: image/png");
$image = imagecreate(100, 100);
$white = ImageColorAllocate ($image, 255, 255, 255);//Set this first as the
background colour
$black = imagecolorallocate($image, 0, 0, 0);
ImageString($image,2,2,2,$name,$black);
ImageInterlace($image, 1);
ImagePNG($image);
}else{
header("Content-type: image/png");
$image = imagecreate(100, 100);
$white = ImageColorAllocate ($image, 255, 255, 255);//Set this first as the
background colour
$black = imagecolorallocate($image, 0, 0, 0);
ImageString($image,2,2,2,"name is not set!",$black);
ImageInterlace($image, 1);
ImagePNG($image);
}
}
else{
echo"Main Form:<FORM ACTION=\"$SCRIPT_NAME\" METHOD=\"POST\">
<INPUT TYPE=\"text\" NAME=\"name\" value=\"$name\">
<INPUT TYPE=submit name=\"Submit\">
<center><img src=\"$SCRIPT_NAME?submit=Display\"></center>
</FORM>
";
}
//session_unregister("name"); //<------Tried this & failed
?>