Email form

design

#1

Hey guys so Im trying to add a contact form on my blog…I thought it was working fine until i checked my webmail. I even changed it to an actual email and still no message.

I am getting the contact form via :http://www.freecontactform.com/email_form.php
And I was trying to follow the instructions word by word, however, I did not need the Last Name and Telephone in the forum just Name, Email, Website, Message.

This is the location of the form itself - blog.beautybybelle.com/contact.php
and this is the code I’m using after including it in my design and tweaked the form by removing telephone and last name.

<?php include('header.php'); ?>
<div id="content">
<div id="navigation">
<ul id="navi">
<h2>Site</h2>
<li><a href="#">Home</a></li>
<li><a href="about.php">About</a></li>
<li><a href="contact.php">Contact</a></li>
<li><a href="credits.php">Credits</a></li>

<h2>Social Media</h2>
<li><a href="http://www.beautybybelle.net">My Beauty Blog</a></li>
<li><a href="http://www.mischievous-designs.net">Graphics Site</a></li>
<li><a href="http://www.facebook.com/mischievousx3">My Facebook</a></li>
<li><a href="http://www.instagram.com/mischx3">My Instagram</a></li>

<h2>Extras</h2>
<li><a href="links.php">Link In/Out</a></li>
<li><a href="archives.php">Archives</a></li>
<li><a href="beautybybelle.net">My Host</a></li>
</ul>
<div id="naviFoot"></div>
</div>

<div id="info">
<h1>Thank you</h1>
Thank you for contacting us. We will be in touch with you very soon.
<br><br>
 
<?php

if(isset($_POST['email'])) {
 
     
 
    // EDIT THE 2 LINES BELOW AS REQUIRED
 
    $email_to = "mischievousx3@gmail.com";
 
    $email_subject = "BLOG CONTACT";
 
     
 
     
 
    function died($error) {
 
        // your error code can go here
 
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
 
        echo "These errors appear below.<br /><br />";
 
        echo $error."<br /><br />";
 
        echo "Please go back and fix these errors.<br /><br />";
 
        die();
 
    }
 
     
 
    // validation expected data exists
 
    if(!isset($_POST['first_name']) ||
 
        !isset($_POST['email']) ||
 
        !isset($_POST['website']) ||
 
        !isset($_POST['comments'])) {
 
        died('We are sorry, but there appears to be a problem with the form you submitted.');       
 
    }
 
     
 
    $first_name = $_POST['first_name']; // required
 
    $email_from = $_POST['email']; // required
 
    $telephone = $_POST['website']; // not required
 
    $comments = $_POST['comments']; // required
 
     
 
    $error_message = "";
 
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
 
  if(!preg_match($email_exp,$email_from)) {
 
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
 
  }
 
    $string_exp = "/^[A-Za-z .'-]+$/";
 
  if(!preg_match($string_exp,$first_name)) {
 
    $error_message .= 'The First Name you entered does not appear to be valid.<br />';
 
  }
 
  if(!preg_match($string_exp,$last_name)) {
 
    $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
 
  }
 
  if(strlen($comments) < 2) {
 
    $error_message .= 'The Comments you entered do not appear to be valid.<br />';
 
  }
 
  if(strlen($error_message) > 0) {
 
    died($error_message);
 
  }
 
    $email_message = "Form details below.\n\n";
 
     
 
    function clean_string($string) {
 
      $bad = array("content-type","bcc:","to:","cc:","href");
 
      return str_replace($bad,"",$string);
 
    }
 
     
 
    $email_message .= "First Name: ".clean_string($first_name)."\n";
 
    $email_message .= "Email: ".clean_string($email_from)."\n";
 
    $email_message .= "Website: ".clean_string($website)."\n";
 
    $email_message .= "Comments: ".clean_string($comments)."\n";
 
     
 
     
 
// create email headers
 
$headers = 'From: '.$email_from."\r\n".
 
'Reply-To: '.$email_from."\r\n" .
 
'X-Mailer: PHP/' . phpversion();
 
@mail($email_to, $email_subject, $email_message, $headers);  
 
?>
 

 
<?php
 
}
 
?>
</div>
<?php include('footer.php'); ?>

^ thats the action of the form…this is the form

[code]

<?php include('header.php'); ?>

CONTACT ME

Hey guys, if you guys ever want to contact me for whatever reason, this is the place. You can use the form provided below to do so. I love feedbacks and if you guys have any questions regarding anything, again, please tell me.

I don't know when I can get back to you but it will be within 24 hours. However, if you check out my social media links down below, you can contact me there as well as long as you are registered through them.

P.S. I do NOT respond to any scams whatsoever and they will go straight to my trash so
please don’t bother. Thank you.



Belle xo


Name:

Email Address:

Website

Comments *

<?php include('footer.php'); ?>[/code]

Ive been hosted by Dreamhost for forever and would like not to be discouraged by a contact form so any help would be greatly appreciated.

Thank you xo


#2

You repeated your paste a 2nd time rather than paste the form.

The most common problem is the contact form must send FROM a valid email on your domain. It can’t for example be sent FROM the email address a user supplied on the form, which at one time was a standard way of doing things and many pre-coded forms use that logic. With Yahoo’s recent policy change, it’s become harder to do it that way anyway.

As far as who the email is addressed TO:, the best thing to do is also use an address on your dreamhost domain. You might be able to send TO somewhere else but you will/might have trouble if it’s @AOL, @comcast, or at @gmail…and maybe others as the To address. This includes creating a forward only address that forwards outside your domain, those emails seem to even have a harder time getting thru.

For an even better solution find a form that can be configured to use an SMTP server instead of using php’s mail(). Configure that to log into your mail account at dreamhost and send from there. This is better because dreamhost runs mail accounts on dedicated mail servers and they don’t end up on RBLs like the webservers often do.

(adding:) If it’s critical the emails being generated always be received in a timely fashion, it’s definitely better to find an smtp solution. Dreamhost’s webservers are really not reliable sending php mail()… sometimes it’s delayed hours or days, sometimes it never arrives… while a lot of time it’s no problem at all.


#3

Thanks for replying.
I did use my webmail with dreamhost before I tried my gmail just to see if there was something wrong with Dreamhost…but since I didnt receive the test email on my gmail, I figured it was the email code.

Nonetheless, it was one PHP email form that looked interesting but I know there are others out there. I also tried a non-php email form but I felt closer to being successful with it. If anything, I will just…not use an email form. I will just let them know my email and they can use that to contact me however they want to :slight_smile:

Anyways, thanks for helping me.