Jump to content

michaelramsgate

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Everything posted by michaelramsgate

  1. phew, it works. I need to revisit, the differences in your code. I do have the 'phone' value in the form, even though the phone variable is being inserted in the message, do I still need to define it, under the lists of variables in the top?
  2. <?php include 'config.php'; error_reporting (E_ALL ^ E_NOTICE); $post = (!empty($_POST)) ? true : false; if($post) { include 'functions.php'; $name = stripslashes($_POST['contactname']); $email = trim($_POST['email']); $subject = "New Message"; $message = stripslashes($_POST['message']); $message .= "\n\n"; $message = $message . "Customer Phone Number is " . $phone; $error = ''; // Check name if(!$name) { $error .= 'Please enter your name.<br />'; } // Check email if(!$email) { $error .= 'Please enter an e-mail address.<br />'; } if($email && !ValidateEmail($email)) { $error .= 'Please enter a valid e-mail address.<br />'; } // Check message (length) if(!$message || strlen($message) < 15) { $error .= "Please enter your message. It should have at least 15 characters.<br />"; } if(!$error) { $mail = mail(WEBMASTER_EMAIL, $subject, $message, "From: ".$name." <".$email.">\r\n" ."Reply-To: ".$email."\r\n" ."X-Mailer: PHP/" . phpversion()); if($mail) { echo 'OK'; } } else { echo '<div class="notification_error">'.$error.'</div>'; } } ?> functions include <?php function ValidateEmail($email) { /* (Name) Letters, Numbers, Dots, Hyphens and Underscores (@ sign) (Domain) (with possible subdomain(s) ). Contains only letters, numbers, dots and hyphens (up to 255 characters) (. sign) (Extension) Letters only (up to 10 (can be increased in the future) characters) */ $regex = '/([a-z0-9_.-]+)'. # name '@'. # at '([a-z0-9.-]+){2,255}'. # domain & possibly subdomains '.'. # period '([a-z]+){2,10}/i'; # domain extension if($email == '') { return false; } else { $eregi = preg_replace($regex, '', $email); } return empty($eregi) ? true : false; } ?>
  3. Thanks for the reply and the explanation, I have a lot to learn. but... the form still does not validate the message. I take those 2 lines out and it validates it. I thought it might be because I am testing it offline in WAMP.
  4. still need some help, I am not sure how to use the above code and still get the rest of the message validated.
  5. this has been really great...thanks for the help just one more question adding this $message = stripslashes($_POST['message']); $message .= "\n\n"; $message = "Customer Phone Number is:" .phone; seems to loose the validation for the message. If I dont put anything in the message field, it does not check and sends anyway. // Check message (length) if(!$message || strlen($message) < 15) { $error .= "Please enter your message. It should have at least 15 characters.<br />"; } if(!$error) { $mail = mail(WEBMASTER_EMAIL, $subject, $message, "From: ".$name." <".$email.">\r\n" ."Reply-To: ".$email."\r\n" ."X-Mailer: PHP/" . phpversion()); if($mail) { echo 'OK'; } } else { echo '<div class="notification_error">'.$error.'</div>'; } }
  6. Thanks for the quick reply....that makes total sense to me now, and sure enough it works. you added $message .= '/n/n'; what exactly is this supposed to do? $message .= "Customer Phone Number is:" .$phone; is there a way to force this its own line of the email.
  7. Thanks for the quick reply....that makes total sense to me now, and sure enough it works. you added $message .= '/n/n'; what exactly is this supposed to do? How would one go about styling it further to say $message= The customer's phone number is =$phone;
  8. First off, I am new to PHP, and want to learn it, but it seems very complicated. Where do I begin? I found a script online for a contact form and I am having trouble making it work for my needs. I wanted to include a phone number field in the email message. This is what I have so far for the PHP, but it does not include the phone field in the body of the message. Everything else works fine. Apologize in advance if this message has been posted many times before. <?php $post = (!empty($_POST)) ? true : false; if($post) { include 'functions.php'; $name = stripslashes($_POST['contactname']); $email = trim($_POST['email']); $subject = "New Message from your website"; $message = stripslashes($_POST['message']); $phone = stripslashes($_POST['phone']); $error = ''; // Check name if(!$name) { $error .= 'Please enter your name.<br />'; } // Check email if(!$email) { $error .= 'Please enter an e-mail address.<br />'; } if($email && !ValidateEmail($email)) { $error .= 'Please enter a valid e-mail address.<br />'; } // Check message (length) if(!$message || strlen($message) < 15) { $error .= "Please enter your message. It should have at least 15 characters.<br />"; } if(!$error) { $mail = mail(WEBMASTER_EMAIL, $subject, $message, "From: ".$name." <".$email.">\r\n" ."Reply-To: ".$email."\r\n" ."X-Mailer: PHP/" . phpversion()); if($mail) { echo 'OK'; } } else { echo '<div class="notification_error">'.$error.'</div>'; } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.