php contact form
-
I created a page template named contactform.php and linked my contact page to this template.
here the code:
<?php //Some variables $mymail = "[email protected]"; $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $find = $_POST['find']; $eip = $_POST['eip']; //Function to check email address function checkemail($email) { if(eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$",$email)) { return true; } else { return false; } } //Mail Processing if ($_POST['esubmit']) { //Check for blank fields if ($name == "" || $email == "" || $phone == "") { echo "<p>You left a blank field.<br/>Please try again.</p>";} //Check to see if the email address is valid else if (checkemail($email) == false) { echo "<p>You entered an invalid email address.</p>";} //Send the email if there's no error else { $body = "Name: $name\r\nEmail: $email\r\nPhone: $phone\r\nHow They Found Us: $find\r\n\r\nIp: $eip"; mail($mymail,$name,$body,"From: $email\r\n"); echo "<p>Thank you, $name!<br />Your request has been sent.</p>";} } ?> <form class="form" name="contact" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post"> Name:*<br/> <input type="text" class="text" name="name"><br/> Email:*<br/> <input type="text" class="text" name="email"><br/> Phone:*<br/> <input type="text" class="text" name="phone"><br/> <div style="text-align:center;">How did you hear about us?</div> <select name="find" class="select"> <option value="Choose" selected>Please select...</option> <option value="Magazine">Magazine</option> <option value="Radio">Radio</option> <option value="Newspaper">Newspaper</option> <option value="Other">Other...</option> </select> <input type="submit" name="esubmit" value="Send Mail" class="submit"> <input type="hidden" name="eip" value="<?php echo $_SERVER["REMOTE_ADDR"]; ?>"> </form>
The issue: when i submit the form it takes me to a “not found” page and the form does not get sent via email. I have used this form in other websites (not wordpress, but html created) and it always worked fine. Is there something different within wordpress that i must do? Thanks
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘php contact form’ is closed to new replies.