Ah. Shorter script. I made some changes and got this to run on my server:
<?php
session_start();
$username = $_SESSION['username'];
$email = $_SESSION['email'];
$username = $_POST['username'];
$email = $_POST['email'];
$comments = $_POST['comments'];
stripslashes($username);
if ((!$username) || (!$email) || (!$comments)) {
$error = "Sorry but please fill in all the required fields.";
}
else
{
$_SERVER['REMOTE_ADDR'] = $REMOTE_ADDR;
$ip = $REMOTE_ADDR;
$to = "ME@ME.com";
$date = date("l, F j, Y");
$time = time();
$subject = "Feedback ^^";
$msg = "Feedback from $username.
@ $email!!!
His comments are:
$comments \n\n
At: $ip | $date | $time";
$mailheaders = "From: Feedback<ME@ME.com>";
mail($to, $subject, $msg, $mailheaders);
$error = "Successfully submitted your feedback form! We will reply to your input as soon as possible. Thank you!";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<fieldset><legend align="center">Feedback</legend><br>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2"><div align="center"><?php echo $error; ?></div></td>
</tr>
<tr>
<td width="48%"><div align="right">Name:</div></td>
<td width="52%"><?php echo "<input type=\"text\" name=\"username\" value=\"$username\">"; ?></td>
</tr>
<tr>
<td><div align="right">E-Mail:</div></td>
<td width="52%"><?php echo "<input type=\"text\" name=\"email\" value=\"$email\">"; ?></td>
</tr>
<tr>
<td><div align="right">Comments/Suggestions/Questions/Praises:</div></td>
<td width="52%"><?php echo "<textarea name=\"comments\">$comments</textarea>"; ?></td>
</tr>
<tr>
<td> </td>
<td width="52%"> </td>
</tr>
<tr>
<td height="16"> </td>
<td> </td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="Submit Feedback">
<input type="reset" name="Submit2" value="Clear Form">
</div></td>
</tr>
</table>
</form>
</fieldset>
</body>
First off, the whole "$z" variable is completely uneccessary. That was what was causing your problem. You said "if ($z = 1)", which is always true because that is an assignment, not a comparison. So, it was executing that error section of your script, which includes and exit, which was exiting without outputting anything (hence the blank page). If you just changed it to if ( $z == 1 ), it would work as you meant it to work. However, the whole $z bit is competely unecessary, so I took it out of the above code. Instead, all you have to do is use an else statement. Then the mail() function will only be called when you want it too. Besides, with the exit you weren't printing out anything. Now it actually prints out your error.
I would recommend you search your other script for exit; as well. Chances are you have an exit getting called somewhere that is causing your problem. In fact, search through the whole script for every exit, and put a line above it: print "exit number" and put a new number each time. Chances are your script will print out exactly one line, corresponding to the place that it exited.