Here's the code for the contact form and below that is the send php:
Code: Select all
<form action="" method="post" class="ajax_form">
<fieldset><?php if (!isset($error) || $error == true){ ?><legend><span>To Contact Michael Directly</span></legend>
<p class="<?php echo $the_nameclass; ?>" ><input name="yourname" class="text_input empty" type="text" id="name" size="20" value='<?php echo $the_name?>'/><label for="name">Your Name*</label>
</p>
<p class="<?php echo $the_emailclass; ?>" ><input name="email" class="text_input email" type="text" id="email" size="20" value='<?php echo $the_email?>' /><label for="email">E-Mail*</label></p>
<p><input name="website" class="text_input" type="text" id="website" size="20" value="<?php echo $the_website?>"/><label for="website">Website</label></p>
<p><input name="telephone" class="text_input" type="text" id="telephone" size="20" value="<?php echo $the_telephone?>"/><label for="telephone">Telephone</label></p>
<p><select name='selector'>
<option value="Actor - Independent Film">Actor - Independent Film</option>
<option value="Actor - Stage Play">Actor - Stage Play</option>
<option value="Actor - Student Film">Actor - Student Film</option>
<option value="Director - Sketch Comedy">Director - Sketch Comedy</option>
<option value="Director - Stage Play">Director - Stage Play</option>
<option value="Improviser">Improviser</option>
<option value="Other">Other</option>
<option value="Print Media">Print Media</option>
<option value="Teaching - Improvisation">Teaching - Improvisation</option>
<option value="Teaching - Writing Sketch Comedy">Teaching - Writing Sketch Comedy</option>
<option value="Writing - Sketch Comedy">Writing - Sketch Comedy</option>
<option selected="selected" value="choose">Select an Option</option>
</select>
<label for="selector">How can Michael contribute to your project?*</label>
</p>
<label for="message" class="blocklabel">Your Message*</label>
<p class="<?php echo $the_messageclass; ?>"><textarea name="message" class="text_area empty" cols="40" rows="7" id="message" ><?php echo $the_message ?></textarea></p>
<p>
<input type="hidden" id="myemail" name="myemail" value="<?php echo $email_adress_reciever; ?>" />
<input type="hidden" id="myblogname" name="myblogname" value="<?php echo $name_of_your_site; ?>" />
<input name="Send" type="submit" value="Send" class="button" id="send" size="16"/></p>
<?php } else { ?>
<p><h3>Your message has been sent!</h3> Thank you!</p>
<?php } ?>
</fieldset>
</form>
<?php
if(isset($_POST['Send'])){
$error = false;
$the_name = $_POST['yourname'];
$the_email = $_POST['email'];
$the_website = $_POST['website'];
$the_telephone = $_POST['telephone'];
$the_message = $_POST['message'];
$the_selector = $_POST['selector'];
if(!checkmymail($the_email))
{
$error = true;
$the_emailclass = "error";
}else{
$the_emailclass = "valid";
}
if($the_name == "")
{
$error = true;
$the_nameclass = "error";
}else{
$the_nameclass = "valid";
}
if($the_message == "")
{
$error = true;
$the_messageclass = "error";
}else{
$the_messageclass = "valid";
}
if($error == false)
{
$to = $_POST['myemail'];
$subject = "New Message from " . $_POST['myblogname'];
$header = 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$header .= 'From:'. $_POST['email'] . " \r\n";
$message1 = nl2br($_POST['message']);
$message = "New message from $the_name <br/>
Mail: $the_email <br />
Website: $the_website <br />
Telephone: $the_telephone <br />
How can Michael contribute to your project?: $the_selector <br />
Message: $message1<br />";
mail($to,
$subject,
$message,
$header);
if(isset($_POST['ajax'])){
echo"<h3>Your message has been sent!</h3><p> Thank you!</p>";
}
}
}
function checkmymail($mailadresse){
$email_flag=preg_match("!^\w[\w|\.|\-]+@\w[\w|\.|\-]+\.[a-zA-Z]{2,4}$!",$mailadresse);
return $email_flag;
Logged