Issue with one page site contact form - php

i have a one page portfolio with a contact form, i have been trying to troubleshoot this thing but have not succeeded. I am no PHP expert so I will try to explain as best as I can. Basically what I have is a contact template file from word press that i have used in the past, but what i want to do is (if possible) implement in my portfolio. My main issue is that when I preview my site in the browser it shows the PHP code that is on the form.
<?php
if ($_SERVER['REQUEST_METHOD'] == "POST") {
// Check fields for errors
if (empty($_POST["txtName"])) {
$errors["txtName"] = "Please enter your name.";
}
if (empty($_POST["txtPhone"])) {
$errors["txtPhone"] = "Please enter your phone number.";
}
if (empty($_POST["txtEmail"])) {
$errors["txtEmail"] = "Please enter your email address.";
} else {
if (!eregi('^[[:alnum:]][a-z0-9_\.\-]*#[a-z0-9\.\-]+\.[a-z]{2,4}$', stripslashes(trim($_POST["txtEmail"])))) {
$errors["txtEmail"] = "Please provide a valid email address.";
}
}
if (count($errors) < 1) {
$to = "test-email#gmail.com";
$subject = 'Bave Designs Contact';
$headers = "From:" . $_POST["txtEmail"] . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$message = '<html><body style="font-family:Arial, Helvetica, sans-serif; font-size:12px;">';
$message .= '<p><strong>Name:</strong> ' . $_POST["txtName"] . '<br />
<strong>Phone:</strong> ' . $_POST["txtPhone"] . '<br />
<strong>Email:</strong> ' . $_POST["txtEmail"] . '<br />
<strong>Message:</strong><br />' . $_POST["txtComment"] . '</p>
</body>
</html>';
if ( !mail($to,$subject,$message,$headers) ) {
$errors["send"] = "There was a problem sending your message. Please try again.";
}
}
}
<div id="contact-form">
<?php
if (count($errors) > 0) {
echo '<ul style="color:red; padding:0 0 18px 22px;">';
foreach ($errors as $error) {
echo "<li>" . $error . "</li>";
}
echo "</ul>";
}
?>
<?php if ($_SERVER['REQUEST_METHOD'] == "POST" && count($errors) < 1) { ?>
<p class="success-message"><?php _e('Thank you! Your message has been sent.'); ?></p>
<?php } else { ?>
<form id="contact1" method="post" action="#message" class="contact-form">
<p><label for="txtName">Name</label>
<input type="text" id="txtName" name="txtName" class="field" size="40" value="<?php echo $_POST['txtName'] ?>" /></p>
<p><label for="txtPhone">Phone</label>
<input type="text" id="txtPhone" name="txtPhone" class="field" size="40" value="<?php echo $_POST['txtPhone'] ?>" /></p>
<p><label for="txtEmail">Email</label>
<input type="text" id="txtEmail" name="txtEmail" class="field" size="40" value="<?php echo $_POST['txtEmail'] ?>" /></p>
<p><label for="txtComment">Message</label>
<textarea name="txtComment" id="txtComment" class="field" cols="40" rows="10"><?php echo $_POST['txtComment'] ?></textarea></p>
<p><input type="submit" id="btnSubmit" name="btnSubmit" class="button" value="Submit" /></p>
</form>
<?php } ?>
</div><!-- CONTACT FORM ENDS-->
I switched the wp_mail function to mail which I know is correct.
Any help would be appreciated.
Thanks in advance.

My main issue is that when I preview my site in the browser it shows
the PHP code that is on the form.
So, if I understand correctly, your PHP codes are being shown in your page?
If that is the case, I urge you to contact your webhosting provider asap, because there seems to be a big problem with your Apache configuration.

Related

Contact form not providing error, confirmation or email

I've used this same form a number of times but this particular occasion it doesn't seem to actually be sending any email nor providing me any error messages or confirmation.
The output of the: print_r($_POST); from a test just a moment ago is the following:
Array ( [Name] => test name [Email] => test#test.com [Company] => example company [Position] => ceo [Captcha] => 1 )
So the form is grabbing all details correctly and attempting to pass them on, but no email or confirmation/error(s).
PHP / HTML
<?php
if (count($error)>=1) {
foreach($error as $one_error) {
echo '<h3>'.$one_error.'</h3>';
echo '<div class="clear"></div>';
}
}
if ($message_sent) {
echo '<h2>Thank you for your request. We will be in touch soon!</h2>';
echo '<hr class="hr" />';
}
?>
<form action="index.php" method="POST">
<span>
<label><strong>Name</strong></label><br />
<input type="text" name="Name" placeholder="Name" value="<?=$Name;?>" required />
</span>
<span>
<label><strong>Your Email Address</strong></label><br />
<input type="text" name="Email" placeholder="Email Address" value="<?=$Email;?>" required />
</span>
<br /><br />
<span>
<label><strong>Company</strong></label><br />
<input type="text" name="Company" placeholder="Company" value="<?=$Company;?>" required />
</span>
<span>
<label><strong>Position</strong></label><br />
<input type="text" name="Position" placeholder="Company Position" value="<?=$Position;?>" required />
</span>
<br /> <br />
<label><strong>Captcha</strong></label><br />
<img src="<?php HTTP_HOST ?>/Contact/answer.php">
<input type="text" placeholder="Enter Sum Calculation" name="Captcha" value="<?=$Captcha;?>" required />
<div class="clear"></div><br />
<input type="submit" value="Send Enquiry" />
</form>
PHP (Inside of the same index.php file)
<?php
session_start();
print_r($_POST);
// print_r($_SESSION['code']);
function isValidInetAddress($data, $strict = false) {
$regex = $strict ? '/^([.0-9a-z_-]+)#(([0-9a-z-]+\.)+[0-9a-z]{2,4})$/i' : '/^([*+!.&#$¦\'\\%\/0-9a-z^_`{}=?~:-]+)#(([0-9a-z-]+\.)+[0-9a-z]{2,4})$/i';
if (preg_match($regex, trim($data), $matches)) {
return array($matches[1], $matches[2]);
} else {
return false;
}
}
$Name = '';$Email = '';$Company = '';$Position = '';$Captcha = '';
if (isset($_POST)&&(isset($_POST['Submit'])&&(strlen($_POST['Submit'])>1))) {
$error = array();
if (isset($_POST['Name'])&&(strlen($_POST['Name'])>1)) {
$Name = $_POST['Name'];
} else {
$error[]='Name is empty';
}
if (isset($_POST['Email'])&&(strlen($_POST['Email'])>1)) {
$Email = $_POST['Email'];
} else {
$error[]='Email is empty';
}
if (isset($_POST['Company'])&&(strlen($_POST['Company'])>1)) {
$Company = $_POST['Company'];
} else {
$error[]='Company is empty';
}
if (isset($_POST['Position'])&&(strlen($_POST['Position'])>1)) {
$Position = $_POST['Position'];
} else {
$error[]='Position is empty';
}
if (isset($_POST['Captcha'])&&($_POST['Captcha']==$_SESSION['code'])) {
} else {
$error[]='Captcha is wrong';
}
if (count($error)<1) {
$headers = 'From: jordan#gmail.com' . "\r\n" .
'Reply-To: jordan#gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$message ='New DiSC Profile Request'."\r\n";
$message .= 'Name: '.$Name."\r\n";
$message .= 'Email: '.$Email."\r\n";
$message .= 'Company: '.$Company."\r\n";
$message .= 'Position: '.$Position."\r\n";
mail('jordan#gmail.com', 'New DiSC Profile Request', $message, $headers);
// mail('galin#mangcreative.com', 'New Enquiry from Urban Country', $message, $headers);
unset($Name);unset($Email);unset($Company);unset($Position);
$message_sent = TRUE;
}
}
?>
Change the form submit button and give it a name
<input type="submit" value="Send Enquiry" />
to
<input type="submit" value="Send Enquiry" name="Submit"/>
You need to have name="" on the button;
<input type="submit" value="Send Enquiry" name="submit" />
You also don't need to have action="index.php" if the php is on the same page;
<form action="" method="POST">
Also you don't need
if (isset($_POST)&&(isset($_POST['Submit'])&&(strlen($_POST['Submit'])>1))) {
Use: if (isset($_POST['submit'])===true) {

How do I get my external send mail php file to check if the captcha is correct

I have an email form on a website that sends the form data to an external php file (contact-form-handler.php) I have recently tried to add a captcha however I have been unsuccessful in getting the external php file to check if the captcha code was entered correctly.. At the moment it says that it is incorrect even when I enter the correct code.
The website is bathroomdesignperth.com.au
Form code:
<?php
$_SESSION['code'] = sha1('Same text as in the image');
?>
<form method="POST" name="contact_form" action="/templates/onlinespark/contact-form-handler.php">
<label for='name'>Name: </label>
<input type="text" name="name" value='<?php echo htmlentities($name) ?>'>
<label for='email'>Email: </label>
<input type="text" name="email" value='<?php echo htmlentities($visitor_email) ?>'>
<label for='phone'>Phone: </label>
<input type="text" name="phone" value='<?php echo htmlentities($phone) ?>'>
<label for='message'>Message:</label>
<textarea name="message" rows=8 cols=30><?php echo htmlentities($user_message) ?></textarea>
<label><img src="/templates/onlinespark/captcha.php"></label>
<input type="text" name="code">
<input type="submit" value="Submit" name='submit' class="quoteButton">
</form>
Php code:
<?php
if (isset($_POST['submit'])) {
$error = "";
if (!empty($_POST['name'])) {
$name = $_POST['name'];
} else {
$error .= "You didn't type in your name. <br />";
}
if (!empty($_POST['phone'])) {
$name = $_POST['phone'];
} else {
$error .= "You didn't enter your phone. <br />";
}
if (!empty($_POST['email'])) {
$email = $_POST['email'];
if (!preg_match("/^[a-z0-9]+(\.[_a-z0-9-]+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email)){
$error .= "The e-mail address you entered is not valid. <br/>";
}
} else {
$error .= "You didn't type in an e-mail address. <br />";
}
if (!empty($_POST['message'])) {
$message = $_POST['message'];
} else {
$error .= "You didn't type in a message. <br />";
}
if(sha1($_POST['code']) == $_SESSION['code']) {
$code = $_POST['code'];
} else {
$error .= "The captcha code you entered does not match. Please try again. <br />";
}
if (empty($error)) {
$from = 'From: ' . $name . ' <' . $email . '>';
$to = "mail#email.com.au";
$subject = "New contact form message";
$content = $name . " has sent you a message: \n" . $message;
$success = "<h3>Thank you! Your message has been sent!</h3>";
mail($to,$subject,$content,$from);
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>ERROR - Please fill in all fields!</title>
</head>
<body>
<!-- This page is displayed only if there is some error -->
<h1>ERROR - Please go back and fill in all fields!</h1>
<?php
if (!empty($error)) {
echo '<p class="error"><strong>Your message was NOT sent<br/> The following error(s) returned:</strong><br/>' . $error . '</p>';
} elseif (!empty($success)) {
echo $success;
}
?>
</body>
</html>
Send the correct answer to the captcha in an encoded form to the external php file via POST.
<?php $salt = 'some-random-text'; ?>
<input type="text" name="code" />
<input type="hidden" name="code_key" value="<?php echo sha1('Text in the image' . $salt); ?>" />
In the PHP code, instead of using the session value, check the posted 'code_key'.
$salt = 'some-random-text'; // same salt string as in the original file
if ($_POST['code_key'] == sha1($_POST['code'] . $salt)) {
// captcha is correct
} else {
// captcha is wrong
}
This works perfectly for captcha checks across different domains. Note that $salt parameter is for added security.

Pass a variable from one PHP file to another via $.post

I have a contact form that passes the data via jQuery $.post.
JS
$(function () {
$("#contact_form").submit(function (a) {
a.preventDefault();
$.post("<?php echo home_url('/_asset/contact.php'); ?>", {
contact_name : $("#contact_name").val(),
contact_email : $("#contact_email").val(),
contact_subject : $("input:radio[name=subject]:checked").val(),
contact_textarea: $("#contact_textarea").val(),
contact_postid : $("#contact_postid").val(),
}, function (a) {
$("div#response").removeClass("hidden");
$("div#response").delay(1E3).html(a);
});
});
});
contact.php
$contact_name = $_POST['contact_name'];
$contact_email = $_POST['contact_email'];
$contact_subject = $_POST['contact_subject'];
$contact_message = $_POST["contact_textarea"];
$contact_postid = $_POST['contact_postid'];
$contact_address = $_SERVER['REMOTE_ADDR'];
if( empty($contact_name) && empty($contact_email) && empty($contact_subject) && empty($contact_message) ) {
die('You must fill out all fields amigo!');
}
// Build that email boy!
if( !empty($contact_postid) ) { $email_id = ' (' . $contact_postid . ')'; }
$email_to = 'email#example.com';
$email_subject = 'Contact Form: ' . $contact_subject . $email_id;
$email_header = 'From: ' . $contact_name . '<' . $contact_email . '>' . "\r\n";
$email_header .= 'Reply-To:' . $contact_email . "\r\n";
$email_header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$email_message = nl2br($contact_message);
// Try sending the email
if(!mail($email_to, $email_subject, $email_message, $email_header)){
$status = 'red';
die('Error sending email.');
} else {
$status = 'green';
die('Email sent!');
}
PHP form
<div class="respond_form">
<form method="post" id="contact_form">
<h2>Let's get contacting!</h2>
<div id="response" class="hidden alert <?php echo $status; ?>"></div>
<div class="line">
<label for="contact_name" title="Please enter your name (required)">Your name <span class="required">*</span></label>
<input type="text" name="contact_name" id="contact_name" tabindex="1" placeholder="John Smith" required="required"/>
</div>
<div class="line">
<label for="contact_email" title="Please enter your email (required)">Your email (so we can contact you) <span class="required">*</span></label>
<input type="email" name="contact_email" id="contact_email" tabindex="2" placeholder="mail#example.com" required="required"/>
</div>
<?php if( isset($_GET['subject']) ) { ?>
<input hidden="hidden" name="subject" type="radio" value="<?php echo $_GET['subject']; ?>" checked="checked">
<?php if( isset($_GET['PostID']) ) { echo '<input hidden="hidden" id="contact_postid" name="postid" type="input" value="' . $_GET['PostID'] . '">'; } ?>
<?php } else { ?>
<div class="line">
<label>What is the message in regards to? <span class="required">*</span></label>
<ul style="list-style:none; margin: 0; padding: 0;">
<label style="font-weight:normal;"><input style="margin-right: 10px;" name="subject" type="radio" value="Advertising"<?php if( $_GET['subject'] == 'advertising' ) { echo ' checked="checked"'; } ?>>Advertising</label>
<label style="font-weight:normal;"><input style="margin-right: 10px;" name="subject" type="radio" value="Contribute an Article"<?php if( $_GET['subject'] == 'contribute' ) { echo ' checked="checked"'; } ?>>Contribute an Article</label>
</ul>
</div>
<?php } ?>
<div class="line">
<label for="contact_textarea" title="Briefly explain your message (required)">Briefly explain your message <span class="required">*</span></label>
<textarea name="contact_textarea" id="contact_textarea" rows="10" tabindex="3" maxlength="500" required="required"></textarea>
</div>
<input type="submit" id="contact_send" name="contact_send" class="button glow" value="Send Message"/>
</form>
</div>
As you can see, I've tried setting a $status in the mail() function but that didn't work. I'm not entirely sure what's going on with the whole thing (found it ages ago and just built around it) but I know the die() message emits into the div#response.
Effectively I was hoping to add a class to the div#response if the email was successful or not.
OH! and incase someone wants to comment on the lack of security, or checking of $_POST data, I've stripped it for here :]
$.post sends the data to contact.php and loads its response.
In your case, the response is text that can be "Error sending email." or "Email sent!" (from what you posted) so you just need to test the value and add the related class.
$(function () {
$("#contact_form").submit(function (a) {
a.preventDefault();
$.post("<?php echo home_url('/_asset/contact.php'); ?>", {
contact_name : $("#contact_name").val(),
contact_email : $("#contact_email").val(),
contact_subject : $("input:radio[name=subject]:checked").val(),
contact_textarea: $("#contact_textarea").val(),
contact_postid : $("#contact_postid").val(),
}, function (a) {
$("div#response").removeClass("hidden").addClass( (a=="Email sent!") ? "email-success" : "email-error" );
$("div#response").delay(1E3).html(a);
});
});
});

PHP Trying to add ability to send attachment to working contact us form

I have a friend who asked me to modify her website's contact form to request phone number and also the ability to add photo attachments. I've added the code necessary to request and send the phone number with the email, but adding the ability to attach photo files is beyond the current scope of my knowledge. Could someone take a look at the code and tell me how to add the ability to attach files to the message? All I'm trying to do is add this below the current message field, but it's proving to be more involved than I expected. Since everything I tried has broken the current form, I've removed my code attempts to add the attachment and I'm posting the code as it currently works. It's my hope someone with a better grasp of php can help us with this.
<?php
//set the level of error reporting
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
// Set-up these 3 parameters
$to = 'any#somewhere.net';
$subject = 'Question from The website';
$contact_submitted = 'Your message has been sent.';
function email_is_valid($email) {
return preg_match('/^[A-Z0-9._%+-]+#[A-Z0-9.-]+\.[A-Z]{2,4}$/i',$email);
}
if (!email_is_valid($to)) {
echo '<p style="color: red;">You must set-up a valid (to) email address before this contact page will work.</p>';
}
if (isset($_POST['contact_submitted'])) {
$return = "\n\r";
$youremail = trim(htmlspecialchars($_POST['your_email']));
$yourname = stripslashes(strip_tags($_POST['your_name']));
$yourphone = trim(htmlspecialchars($_POST['your_phone']));
$yourmessage = stripslashes(strip_tags($_POST['your_message']));
$contact_name = "Name: ".$yourname;
$contact_email = "Email Address: ".$youremail;
$contact_phone = "Phone: ".$yourphone;
$message_text = "Message: ".$yourmessage;
$user_answer = trim(htmlspecialchars($_POST['user_answer']));
$answer = trim(htmlspecialchars($_POST['answer']));
$message = $contact_name . $return . $contact_email . $return . $contact_phone . $return . $return . $message_text;
$headers = "From: ".$youremail;
if (email_is_valid($youremail) && !eregi("\r",$youremail) && !eregi("\n",$youremail) && $yourname != "" && $yourphone != "" && $yourmessage != "" && substr(md5($user_answer),5,10) === $answer) {
mail($to,$subject,$message,$headers);
$yourname = '';
$youremail = '';
$yourphone = '';
$yourmessage = '';
echo '<p style="color: blue;">'.$contact_submitted.'</p>';
}
else echo '<p style="color: red;">Please enter your name, a valid email address, your message and the answer to the simple maths question before sending your message.</p>';
}
$number_1 = rand(1, 9);
$number_2 = rand(1, 9);
$answer = substr(md5($number_1+$number_2),5,10);
?>
<form id="contact" action="contact.php" method="post">
<div class="form_settings">
<p><span>Name:</span><input class="contact" type="text" name="your_name" value="<?php $yourname; ?>" /></p>
<p><span>Email Address:</span><input class="contact" type="text" name="your_email" value="<?php $youremail; ?>" /></p>
<p><span>Phone Number:</span><input class="contact" type="text" name="your_phone" value="<?php $yourphone; ?>" /></p>
<p><span>Message:</span><textarea class="contact textarea" rows="1" cols="50" name="your_message"><?php $yourmessage; ?></textarea></p>
<p style="line-height: 1.7em;">To help prevent spam, please enter the answer to this question:</p>
<p><span><?php echo $number_1; ?> + <?php echo $number_2; ?> = ?</span><input type="text" name="user_answer" /><input type="hidden" name="answer" value="<?php echo $answer; ?>" /></p>
<p style="padding-top: 15px"><span> </span><input class="submit" type="submit" name="contact_submitted" value="send" /></p>
</div>
</form>
If anyone can figure this out I'd be forever grateful.
First problem you're going to have is that you're not going to be able to upload any file without indicating the
enctype="multipart/form-data"
within the form tag.
The rest of the info, you could refer to this tutorial

Form contents not showing in email

This is a followup to a question I posted yesterday. I thought everything was working fine, but today, I am not getting any results in the email from the drop down field.
Here is the form code in question:
<form method="post" action="contact.php" name="contactform" id="contactform">
<fieldset>
<legend>Please fill in the following form to contact us</legend>
<label for="name"><span class="required">*</span> Your Name</label>
<input name="name" type="text" id="name" size="30" value="" />
<br />
<label for="company">Company</label>
<input name="company" type="text" id="company" size="30" value="" />
<br />
<label for="email"><span class="required">*</span> Email</label>
<input name="email" type="text" id="email" size="30" value="" />
<br />
<label for="phone"><span class="required">*</span> Phone</label>
<input name="phone" type="text" id="phone" size="30" value="" />
<br />
<label for="purpose"><span class="required">*</span> Purpose</label>
<select name="purpose" id="purpose" style="width: 300px; height:35px;">
<option value="none selected" selected="selected">-- Select One --</option>
<option value="I am interested in your services">I am interested in your services!</option>
<option value="I am interested in a partnership">I am interested in a partnership!</option>
<option value="I am interested in a job">I am interested in a job!</option>
</select>
<br />
<label for=comments><span class="required">*</span> Comments</label>
<textarea name="comments" cols="40" rows="3" id="comments" style="width: 350px;"></textarea>
<p><span class="required">*</span> Please help us control spam.</p>
<label for=verify accesskey=V> 3 + 1 =</label>
<input name="verify" type="text" id="verify" size="4" value="" style="width: 30px;" /><br /><br />
<input type="submit" class="submit" id="submit" value="Submit" />
</fieldset>
</form>
It is then processed in PHP and should output the selected option to an email, however the Reason for Contact line always comes through with nothing in it.
Here is the PHP code:
<?php
if(!$_POST) exit;
$name = $_POST['name'];
$company = $_POST['company'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$purpose = $_POST['purpose'];
$comments = $_POST['comments'];
$verify = $_POST['verify'];
if(trim($name) == '') {
echo '<div class="error_message">Attention! You must enter your name.</div>';
exit();
} else if(trim($email) == '') {
echo '<div class="error_message">Attention! Please enter a valid email address.</div>';
exit();
} else if(trim($phone) == '') {
echo '<div class="error_message">Attention! Please enter a valid phone number.</div>';
exit();
} else if(!isEmail($email)) {
echo '<div class="error_message">Attention! You have enter an invalid e-mail address, try again.</div>';
exit();
}
if(trim($comments) == '') {
echo '<div class="error_message">Attention! Please enter your message.</div>';
exit();
} else if(trim($verify) == '') {
echo '<div class="error_message">Attention! Please enter the verification number.</div>';
exit();
} else if(trim($verify) != '4') {
echo '<div class="error_message">Attention! The verification number you entered is incorrect.</div>';
exit();
}
if($error == '') {
if(get_magic_quotes_gpc()) {
$comments = stripslashes($comments);
}
// Configuration option.
// Enter the email address that you want to emails to be sent to.
// Example $address = "joe.doe#yourdomain.com";
$address = "myname#email.com";
// Configuration option.
// i.e. The standard subject will appear as, "You've been contacted by John Doe."
// Example, $e_subject = '$name . ' has contacted you via Your Website.';
$e_subject = 'You\'ve been contacted by ' . $name . '.';
// Configuration option.
// You can change this if you feel that you need to.
// Developers, you may wish to add more fields to the form, in which case you must be sure to add them here.
$e_body = "You have been contacted by $name.\r\n\n";
$e_company = "Company: $company\r\n\n";
$e_content = "Comments: \"$comments\"\r\n\n";
$e_purpose = "Reason for contact: $purpose\r\n\n";
$e_reply = "You can contact $name via email, $email or via phone $phone";
$msg = $e_body . $e_content . $e_company . $e_purpose . $e_reply;
if(mail($address, $e_subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n")) {
// Email has sent successfully, echo a success page.
echo "<fieldset>";
echo "<div id='success_page'>";
echo "<h1>Email Sent Successfully.</h1>";
echo "<p>Thank you <strong>$name</strong>, your message has been submitted to us.</p>";
echo "</div>";
echo "</fieldset>";
} else {
echo 'ERROR!';
}
}
function isEmail($email) { // Email address verification, do not edit.
return(preg_match("/^[-_.[:alnum:]]+#((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i",$email));
}
?>
Any assistance would be greatly appreciated. Thanks!
It really looks like it should work, so I'd verify the dumbly obvious stuff: is your <select> tag contained within the <form> tag? Is 'purpose' mis-typed somewhere (it all looks good here, from what I can see)?
What happens if you do print_r($_POST)?
What happens if you do var_dump($purpose) after it is initialized?
Did you check if the server is able to send emails?
Check if sendmail actually works on your server before trying to debug your code (that seems to be good).

Categories