I have fairly basic knowledge with HTML and CSS, having built my site from scratch. I was using JotForm in an iFrame as my contact form but want to change this to a PHP form so I am not reliant on these guys and I have more control over the look of the form.
I did initially have the form sending an email with blank fields - I tried to fix this and have now completely messed up.
Any help is very much appreciated.
Here is my HTML for the form which is set out in a table;
<table width="400" border="0" align="left" cellpadding="5" id="form">
<tr>
<th width="134" scope="row" align="right">NAME</th>
<th width="240" scope="row">
<form name="name" method="post" action="contact.php">
<span id="sprytextfield1">
<input type="text" name="name" id="name" value="<?php print "$nameField"; ?>">
<span class="textfieldRequiredMsg">A value is required.</span><spanclass="textfieldInvalidFormatMsg">Invalid format.</span></span>
</form></th>
</tr>
<tr>
<th scope="row"> </th>
<th scope="row"> </th>
</tr>
<tr>
<th scope="row" align="right">EMAIL</th>
<th scope="row">
<form name="email" method="post" action="contact.php">
<span id="sprytextfield2">
<input type="text" name="email" id="email" value="<?php print "$emailField"; ?>">
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
</form></th>
</tr>
<tr>
<th scope="row"> </th>
<th scope="row"> </th>
</tr>
<tr>
<th height="128" scope="row" align="right">MESSAGE</th>
<th scope="row">
<form name="message" method="post" action="contact.php">
<span id="sprytextarea1">
<textarea name="message" id="message" cols="45" rows="5"><?php print "$messageField"; ?></textarea>
<span class="textareaRequiredMsg"><br>
A value is required.</span></span>
</form></th>
</tr>
<tr>
<th scope="row"> </th>
<th scope="row"> </th>
</tr>
<tr>
<th scope="row"> </th>
<th scope="row"><form name="submit" method="post" action="contact.php">
<input type="hidden" name="parse_var" id="parse_var" value="contactform">
<input type="submit" name="submit" id="submit" value="SEND MESSAGE">
</form></th>
</tr>
<tr>
<th scope="row"> </th>
<th scope="row"><?php print "$sent"; ?></th>
</tr>
</table>
and my PHP:
<?php
if ($_POST['parse_var'] == "form") {
$emailTitle = 'New Contact Form Message';
$yourEmail = 'charlotte@charlottemay.co.uk';
$emailField = $_POST['email'];
$nameField = $_POST['name'];
$messageField = $_POST['message'];
$body = <<<EOD
<br><hr><br>
Email: $emailField <br />
Name: $nameField <br />
Message: $messageField <br />
EOD;
$headers = "From: $emailField\r\n";
$headers .= "content-type: text/html\r\n";
$success = mail("$yourEmail", "$emailTitle", "$body", "$headers");
$sent = "thankyou, your message has been successfully sent x";
}
?>