I am trying to verify some form fields using javascript but I cant seem to get it to work. Its just a simple html form with a few inputs.. name, phone, message, etc.
Contact.html
<form action="sent.php" method="post" id="myform" enctype="multipart/form-data">
<div id="myform"></div>
<fieldset class="addingenq">
<label>Your Name</label>
<input name="custName" type="text" size="40" >
<label>Phone Number *</label>
<input name="custPhone" type="text" size="40" >
<label>Email Address <em>(Optional)</em></label>
<input name="custEmail" type="text" size="40" >
<label>Enquiry type</label>
<input name="subjectType" type="text" size="40" >
<label>Details about Enquiry</label>
<textarea name="messageType" cols="68" rows="5" class="msg" type="text"></textarea>
<div class="submitbutton">
<input type="submit" name="submit" value="Submit Message" >
</div>
</fieldset>
</form>
Send.php
I attempted to get it return back to contact.html but it just showed a blank sent.php although I did receive the email. Is there a way to make $From something like the custName instead of 'custEmail', as 'custEmail' will not be a requirement on this form.
<?php
if($_POST){
$custName = $_POST ['custName'];
$custPhone = $_POST ['custPhone'];
$custEmail = $_POST ['custEmail'];
$subjectType = $_POST ['subjectType'];
$messageType = $_POST ['messageType'];
}
$subject = "$subjectType";
$message = "
Name: $custName \n\n
Phone Number: $custPhone \n\n
Enquiry type: $subjectType \n\n
Message: $messageType \n\n
";
$from = "From: $custEmail\r\n";
//put your email address here
mail("myemail@mail.com", $subject, $message, $from);
exit;
?>