Forum Moderators: coopster
So what does the unset() line do? Why put it there? I know that unset() basically resets the variables to empty. But like I said, taking it out or leaving it in makes no difference in my testings.
Thanks!
<?php
session_start();unset($sender_error, $address_error, $whichForm);
if(isset($sender)) {
if(empty($sender))
$sender_error = TRUE;
else
$senderName = $sender;
}
if (isset($sender_address)) {
if(empty($sender_address))
$addressForm_error = TRUE;
else
$address = $sender_address;
}
if(isset($submission)) {
if(!($sender_error ¦¦ $addressForm_error)) {
$whichForm = "confirmation";
}
}
unset($submission);
?>
<script language="JavaScript" type="text/JavaScript">
<!--
function errormsg(theField){
if(theField == "sender")
alert("Please write your name in the first blank before sending your message.");
else
alert("Please write your email address in the second blank before sending your message.");
}
//-->
</script>
<?php
if($sender_error) {
echo "<body onload=errormsg('sender')>";
}
else if ($addressForm_error){
echo "<body onload=errormsg('addressForm')>";
}
else{
echo "<body>";
}
?>
<?php
if($whichForm!= "confirmation") {
?>
<form action="<?php echo $PHP_SELF;?>" name="formMail">
<p>Your name:<br>
<?php if(isset($senderName) && $senderName!= "") {?>
<input name="sender" value ="<?php echo $senderName;?>" type="text" size="55">
<?php } else {?>
<input name="sender" type="text" size="55">
<?php }?>
</p>
<p>Your email address:<br>
<?phpif(isset($address) && $address!= "") {?>
<input name="sender_address" value="<?php echo $address;?>" type="text" size="55">
<?php } else {?>
<input name="sender_address" type="text" size="55">
<?php }?>
</p>
<p>
<input type="submit" name="submission" value="Send">
</p>
<?php
}
//if this should display the confirmation message
else {
print "Hello World!";
}
?>