First you have 2 forms in that code:
eg: <form action="">
I think it would be better for you to stick some php in there.
here is a working example of what you want, it is 2 files:
save me as anything.html
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Mail Form - DefecTalisman</title>
<style type="text/css">
<!--
.style1 {font-size: 9px}
-->
</style>
</head>
<body>
<p align="center">Basic Form and engine to work with it</p>
<form method="post" action="engine.php">
<table width="640" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>Your Name :</td>
<td><input type="text" size="50" maxlength="100" name="usr_name" />
* </td>
</tr>
<tr>
<td>Your e-mail Address : </td>
<td><input type="text" size="50" maxlength="100" name="usr_mail" />
*</td>
</tr>
<tr>
<td>Subject : </td>
<td><input type="text" size="50" maxlength="100" name="subject" />
*</td>
</tr>
<tr>
<td>Type Of Message : </td>
<td><select name="msg_type">
<option value='' ="selected">Please Select A Catagory</option>
<option value="support">Support</option>
<option value="c_care">Customer Care</option>
</select>
*</td>
</tr>
<tr>
<td colspan="2"><div align="center">Comments *
<br />
<textarea rows="5" cols="50" name="comments" wrap="physical"></textarea>
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" value="Preview" name="preview" />
<input type="reset" value="Default" />
<input type ="button" value="Back" name ="back" onclick="history.go(-1)" />
</div></td>
</tr>
</table>
</form>
</body>
</html>
save me as "engine.php"
PHP Code:
<?php
// Change to 1 to make it test itself
$test = 0;
/*
* This section is to require inputs from the form
*/
$reqired_fields = array(
'usr_name' => 'Your Name',
'usr_mail' => 'Your e-mail Address',
'subject' => 'Subject',
'msg_type' => 'Type Of Message',
'comments' => 'Comments'
);
$null_fields = array();
foreach ($reqired_fields as $a => $z)
{
if (isset($_POST["$a"]))
{
if ($_POST[$a] == FALSE) { array_push($null_fields,$z); }
}
}
if ($null_fields == TRUE)
{
echo 'These fields are missing :<br>';
foreach ($null_fields as $t) { echo '-'.$t.',<br>'; }
echo '<br>Please press back and fill them in.<br>';
echo '<input type ="button" name ="back" value="Go Back" onclick="history.go(-1)">';
}
/*
* This is where the form gets procesed if it is seen as ok by the checker
*/
if ($null_fields == FALSE)
{
$to = 'XX e-mail-address here XX';
$usr_name = $_POST['usr_name'];
$usr_add = $_POST['usr_mail'];
$type = $_POST['msg_type'];
$sub = $_POST['subject'];
$msg = $_POST['comments'];
echo 'All seems fine.<br>';
echo '<input type="submit" value="Send" name="submit" />';
}
?>