Ok well, I have a basic service script which asks a client what kind of service they want and so on, and it emails me the info, I have all that working, but I also have two checkboxes, one that asks the user if they want hosting with the service, and one that asks if they also want a domain. This is the problem that I am having, the form works correctly until a checkbox is clicked and submitted, the email is not submitted and the page comes back blank which it shouldn't because there should be an error message if the mail failed, but I am getting nothing at all. Well, here is my code:
To Order Our Services, Fill Out The Form Below!
<FORM method="POST" action="<? echo $_SERVER['PHP_SELF']; ?>">
<table>
<TR>
<TD>Name
<TD><INPUT TYPE="text" NAME="name"><br>
</TR>
<TR>
<TD>Service
<TD><INPUT TYPE="text" NAME="service"><br>
</TR>
<TR>
<TD>Description
<TD><TEXTAREA NAME="description" ROWS="5" COLS="35"></TEXTAREA><br>
</TR>
<TR>
<TD>Email
<TD><INPUT TYPE="text" NAME="email"><br>
</TR>
</table>
<a href="hosting.html">Hosting?</a><INPUT TYPE="checkbox" NAME="hosting"> <a href="domain.html">Domain?</a><INPUT TYPE="checkbox" NAME="domain"><br>
<br>
<input type="submit" name="submit" value="Submit!"> <INPUT TYPE="reset"><br><br>
</FORM>
</body>
</html>
<?php
if (isset($submit)) {
if ($name == "") {
echo "<font color=\"red\">Error : Please go back and insert a name.</font>";
die();
} else {
if ($service == "") {
echo "<font color=\"red\">Error : Please go back and insert a service.</font>";
die();
} else {
if ($description == "") {
echo "<font color=\"red\">Error : Please go back and insert a description.</font>";
die();
} else {
if ($email == "") {
echo "<font color=\"red\">Error : Please go back and insert an email address.</font>";
die();
} else {
if (isset($hosting)) {
$hosted = "Yes";
} else {
$hosted = "No";
if (isset($domain)) {
$dom = "Yes";
} else {
$dom = "No";
$subject = "Service from Visual-Orgy";
$line1 = "Name : $name";
$line2 = "Service : $service";
$line3 = "Description : $description";
$line4 = "Email : $email";
$line5 = "Hosting : $hosted";
$line6 = "Domain : $dom";
$line7 = "Please do not email back to this address, because it is just a script.";
$mail = mail("will742@sbcglobal.net", "$subject", "$line1\n\n$line2\n\n$line3\n\n$line4\n\n$line5\n\n$line6\n\n\n\n$line7","From: clients@{$_SERVER['SERVER_NAME']}\r\n" .
"Reply-To: clients@{$_SERVER['SERVER_NAME']}\r\n" .
"X-Mailer: PHP/" . phpversion());
if ($mail) {
echo "<font color=\"green\">Mail Sucessfully Sent!</font>";
} else {
echo "<font color=\"red\">Mail could not be sent!</font>";
}
}
}
}
}
}
}
}
?>
To see an example, go here.
Any help greatly appreciated.
Thanks,
Will 🙂