Php emptying $_post

hello
i am having a play trying to create a simple shopping checkout, using code, no specialist software.
everything is working fine, except when i add or delete an item, and refresh the page, the add/delete is being repeated. which is obviousley bad.
i've tried unsetting the $_posts and emptying any variable being used, but this isn't doing the trick. any ideas....p.s, i'm trying to get the delete item code to work first, so have not altered my add item code.
to test the page, go to http://www.malcmabe.co.uk/custdetails.php
create a username and password using the top columns.click on search for items, and type 'nike' into the search box. click on one of the products and then add x amount to the basket.
if you then f5 refresh, the process is repeated.
in the item code column, type in the item code of the product you have chosen, and choose a quantity to delete. this will delete fine, but if you f5 refresh, another deletion takes place.
here is the code for deletion process:
if(isset($_POST['delitem']))
$code = $_POST['itemcode'];
$quant = $_POST['delquant'];
print("<br/> ".$code." ".$quant);
mysql_query("delete from checkout where itemid = '$code' and username = '$username' LIMIT $quant ");
unset($_POST['delitem']);
unset($_POST['itemcode']);
unset($_POST['delquant']);
$code = null;
$quant = null;
i would appreciate any help. thanks

thanks david
but what i'm getting at, is that if the user adds or deletes an item, and then refreshes for whatever reason, than another item will be added or deleted.
basically, i want no post items to be sent when they refresh the page.
the only time i want data to be sent is when they press a button.

Similar Messages

  • PHP+MySQL query with empty value

    Hi!
    Software is DW8 with Apache 2.0.48, MySQL ver. 4.0.15a, PHP
    4.2.3.
    We had problem when a submitted value for 'regionID' in the
    submit page
    was left blank and the following error message appears in the
    result page:
    "You have an error in your SQL syntax. Check the manual that
    corresponds
    to your MySQL server version for the right syntax to use near
    'LIMIT 0,
    3' at line 1"
    The problem was solved by adding at the top of the page:
    <?php
    if (isset($_POST['regionID']) &&
    empty($_POST['regionID'])) {
    $_POST['regionID'] = '0';
    ?>
    How to change the above code to retrieve ALL records when an
    empty \
    blank value is submitted for 'regionID'?
    TIA
    Nanu

    bbgirl wrote:
    > Something I picked up at a PHP/MySQL seminar...
    $_REQUEST works in place of
    > either $_GET or $_POST. It basically means use either
    get or post. But it is
    > less precise because it can pick up either variable and
    has to think about the
    > request...
    I'm afraid you've picked up rather poor information.
    $_REQUEST relies on
    register_globals being turned on. Since register_globals is
    considered a
    major security risk, the default setting has been off since
    April 2002.
    Many hosting companies have turned register_globals on, in
    spite of the
    security problems, because so many poorly written scripts
    rely on it.
    The PHP development team has decided to resolve this security
    issue once
    and for all by removing register_globals from PHP 6.
    Forget $_REQUEST. Use $_POST and $_GET always. It's safer,
    and it's
    futureproof.
    David Powers
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "Foundation PHP 5 for Flash" (friends of ED)
    http://foundationphp.com/

  • (PHP) $_POST without a form?

    Can $_POST be used when the calling page is not a form?
    I have link that uses the url and $_GET method of
    transferring a
    variable... www.domain.com?variable='something'
    How can this be done without the variable being displayed?
    Can you
    manually set the $_POST variable or do you have to use a
    form?
    Or is it possible to pass variables in another manner?
    Thanks,
    Harvey

    On 15 Oct 2008 in macromedia.dreamweaver, eclipsme wrote:
    > Can $_POST be used when the calling page is not a form?
    >
    > I have link that uses the url and $_GET method of
    transferring a
    > variable... www.domain.com?variable='something'
    >
    > How can this be done without the variable being
    displayed? Can you
    > manually set the $_POST variable or do you have to use a
    form?
    You can manually set $_POST, but it doesn't survive to the
    next page[1].
    > Or is it possible to pass variables in another manner?
    http://www.php.net/manual/en/ref.session.php
    [1]
    post1.php:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
    http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=utf-8">
    <title>Post 1</title>
    </head>
    <body>
    <h1>Hello, World!</h1>
    <p>This page sets certain $_POST variables. <a
    href="post2.php">Go to the next page</a></p>
    <?php
    $_POST['somevar'] = "sumthin";
    $_POST['another'] = "sumthin else";
    ?>
    <pre>
    <?php print_r( $_POST ); ?>
    </pre>
    </body>
    </html>
    post2.php:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
    http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=utf-8">
    <title>Post 2</title>
    </head>
    <body>
    <h1>Goodbye, World!</h1>
    <p>This page may receive certain $_POST
    variables.</p>
    <pre>
    <?php print_r( $_POST ); ?>
    </pre>
    <p>Nope.</p>
    </body>
    </html>
    Joe Makowiec
    http://makowiec.net/
    Email:
    http://makowiec.net/contact.php

  • How do i change the path of data ajax false from returning to homepage, when using a PHP mail form in jquery mobile?

    I have a put a php mail form in the quote page of my mobile site. However when i send the form it returns to the route page rather than the quote page, i have used the data ajax false action as i dont want to send via ajax. i have left the thanks page blank as i want it to remain on the same page showing sent or declined message.  Can someone help please? 
    <?php
    // OPTIONS - PLEASE CONFIGURE THESE BEFORE USE!
    $yourEmail = "[email protected]"; // the email address you wish to receive these mails through
    $yourWebsite = "www.firstcalltransport.co.uk"; // the name of your website
    $thanksPage = ''; // URL to 'thanks for sending mail' page; leave empty to keep message on the same page
    $maxPoints = 4; // max points a person can hit before it refuses to submit - recommend 4
    $requiredFields = "name,email,collection,delivery,comments"; // names of the fields you'd like to be required as a minimum, separate each field with a comma
    // DO NOT EDIT BELOW HERE
    $error_msg = array();
    $result = null;
    $requiredFields = explode(",", $requiredFields);
    function clean($data) {
      $data = trim(stripslashes(strip_tags($data)));
      return $data;
    function isBot() {
      $bots = array("Indy", "Blaiz", "Java", "libwww-perl", "Python", "OutfoxBot", "User-Agent", "PycURL", "AlphaServer", "T8Abot", "Syntryx", "WinHttp", "WebBandit", "nicebot", "Teoma", "alexa", "froogle", "inktomi", "looksmart", "URL_Spider_SQL", "Firefly", "NationalDirectory", "Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot", "crawler", "www.galaxy.com", "Googlebot", "Scooter", "Slurp", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz");
      foreach ($bots as $bot)
      if (stripos($_SERVER['HTTP_USER_AGENT'], $bot) !== false)
      return true;
      if (empty($_SERVER['HTTP_USER_AGENT']) || $_SERVER['HTTP_USER_AGENT'] == " ")
      return true;
      return false;
    if ($_SERVER['REQUEST_METHOD'] == "POST") {
      if (isBot() !== false)
      $error_msg[] = "No bots please! UA reported as: ".$_SERVER['HTTP_USER_AGENT'];
      // lets check a few things - not enough to trigger an error on their own, but worth assigning a spam score..
      // score quickly adds up therefore allowing genuine users with 'accidental' score through but cutting out real spam
      $points = (int)0;
      foreach ($badwords as $word)
      if (
      strpos(strtolower($_POST['comments']), $word) !== false ||
      strpos(strtolower($_POST['name']), $word) !== false
      $points += 2;
      if (strpos($_POST['comments'], "http://") !== false || strpos($_POST['comments'], "www.") !== false)
      $points += 2;
      if (isset($_POST['nojs']))
      $points += 1;
      if (preg_match("/(<.*>)/i", $_POST['comments']))
      $points += 2;
      if (strlen($_POST['name']) < 3)
      $points += 1;
      if (strlen($_POST['comments']) < 15 || strlen($_POST['comments'] > 1500))
      $points += 2;
      if (preg_match("/[bcdfghjklmnpqrstvwxyz]{7,}/i", $_POST['comments']))
      $points += 1;
      // end score assignments
      foreach($requiredFields as $field) {
      trim($_POST[$field]);
      if (!isset($_POST[$field]) || empty($_POST[$field]) && array_pop($error_msg) != "Please fill in all the required fields and submit again.\r\n")
      $error_msg[] = "Please fill in all the required fields and submit again.";
      if (!empty($_POST['name']) && !preg_match("/^[a-zA-Z-'\s]*$/", stripslashes($_POST['name'])))
      $error_msg[] = "The name field must not contain special characters.\r\n";
      if (!empty($_POST['email']) && !preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])(([a-z0-9-])*([a-z0-9]))+ ' . '(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i', strtolower($_POST['email'])))
      $error_msg[] = "That is not a valid e-mail address.\r\n";
      if (!empty($_POST['url']) && !preg_match('/^(http|https):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\ /?/i', $_POST['url']))
      $error_msg[] = "Invalid website url.\r\n";
      if ($error_msg == NULL && $points <= $maxPoints) {
      $subject = "Automatic Form Email";
      $message = "You received this e-mail message through your website: \n\n";
      foreach ($_POST as $key => $val) {
      if (is_array($val)) {
      foreach ($val as $subval) {
      $message .= ucwords($key) . ": " . clean($subval) . "\r\n";
      } else {
      $message .= ucwords($key) . ": " . clean($val) . "\r\n";
      $message .= "\r\n";
      $message .= 'IP: '.$_SERVER['REMOTE_ADDR']."\r\n";
      $message .= 'Browser: '.$_SERVER['HTTP_USER_AGENT']."\r\n";
      $message .= 'Points: '.$points;
      if (strstr($_SERVER['SERVER_SOFTWARE'], "Win")) {
      $headers   = "From: $yourEmail\r\n";
      } else {
      $headers   = "From: $yourWebsite <$yourEmail>\r\n";
      $headers  .= "Reply-To: {$_POST['email']}\r\n";
      if (mail($yourEmail,$subject,$message,$headers)) {
      if (!empty($thanksPage)) {
      header("Location: $thanksPage");
      exit;
      } else {
      $result = 'Your mail was successfully sent.';
      $disable = true;
      } else {
      $error_msg[] = 'Your mail could not be sent this time. ['.$points.']';
      } else {
      if (empty($error_msg))
      $error_msg[] = 'Your mail looks too much like spam, and could not be sent this time. ['.$points.']';
    function get_data($var) {
      if (isset($_POST[$var]))
      echo htmlspecialchars($_POST[$var]);
    ?>
    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Untitled Document</title>
    <link href="CSS/stylesheetnew.css" rel="stylesheet" type="text/css">
    <link href="../jquery-mobile/jquery.mobile-1.0a3.min.css" rel="stylesheet" type="text/css">
    <script src="../jquery-mobile/jquery-1.5.min.js" type="text/javascript"></script>
    <script src="../jquery-mobile/jquery.mobile-1.0a3.min.js" type="text/javascript"></script>
    <style type="text/css">
      p.error, p.success {
      font-weight: bold;
      padding: 10px;
      border: 1px solid;
      p.error {
      background: #ffc0c0;
      color: #F00;
      p.success {
      background: #b3ff69;
      color: #4fa000;
    </style>
    </head>
    <body>
    <div data-role="page" id="home">
      <div data-role="header" data-position="fixed">
       <h1>FIRSTCALL TRANSPORT</h1>
    </div>
        <div data-role="navbar" data-position="fixed">
                                    <ul>
                                      <li><a href="#about">About</a></li>
                                      <li><a href="#services">Services</a></li>
                                      <li><a href="#contact">Contact</a></li>
                                      <li><a href="#quote">Quote</a></li>
                                    </ul>
      </div>
      <div data-role="content"> </div>
         <div data-role="footer" data-position="fixed" > </div>
    </div>
    </div>
    <div data-role="page" id="quote">
      <div data-role="header" data-position="fixed">
        <h1>GET A QUOTE</h1>
      </div>
      <div data-role="content">
       <?php
    if (!empty($error_msg)) {
      echo '<p class="error">ERROR: '. implode("<br />", $error_msg) . "</p>";
    if ($result != NULL) {
      echo '<p class="success">'. $result . "</p>";
    ?>
    <form action="<?php echo basename(__FILE__); ?>" method="post" data-ajax="false"  >
    <noscript>
      <p><input type="hidden" name="nojs" id="nojs" /></p>
    </noscript>
    <p>
      <label for="name">Name: *</label>
      <input type="text" name="name" id="name" value="<?php get_data("name"); ?>" /><br />
      <label for="email">E-mail: *</label>
      <input type="text" name="email" id="email" value="<?php get_data("email"); ?>" /><br />
            <label for="company">Company:</label>
      <input type="text" name="company" id="company" value="<?php get_data("company"); ?>" /><br />
      <label for="collection">Collection: *</label>
      <input type="text" name="collection" id="collection" value="<?php get_data("collection"); ?>" /><br />
        <label for="delivery">Delivery: *</label>
      <input type="text" name="delivery" id="delivery" value="<?php get_data("delivery"); ?>" /><br />
      <label for="comments">Message: *</label>
      <textarea name="comments" id="comments" rows="5" cols="20"><?php get_data("comments"); ?></textarea><br />
      <input type="submit" name="submit" id="submit" value="Send" <?php if (isset($disable) && $disable === true) echo ' disabled="disabled"'; ?> />
    </p>
    </form>  </div>
         <div data-role="footer" >  </div>
      </div>
      </div>           
    </body>
    </html>

    My wife has left me for four weeks, favouring to be with our son who lives 4,000 km away. I now have to cook for myself and the steaks taste horrible. What am I doing wrong?
    If you do not know what I have (not) done to make the steak taste horrible, my question is as hard to answer as your question above.
    Please give us more info like giving us the code that sends the page to the homepage rather than to the previous page.

  • Text box not empty conditional statement

    I've been asked to develop a survey and, in several places, a
    score is given for the completion of text box. However, if there is
    no text in the box, then a score of zero should be given.
    I thought the best way to do this would be to use a hidden
    field with a conditional statement saying "if text box is not empty
    then score=4, else score=0.
    However, firstly I'm not sure how to write this and secondly,
    how do you check if a text box is empty?
    I think it really calls for some human input but the client
    is quite sure this is how he wants it.
    The scores are all going to be inserted into a mysql database
    and sorted out there, so there may be some fudge available there
    but if php could do something nice in the code, that would be
    preferable.
    Thanks in advance.
    Andrew

    Drewbles wrote:
    > However, firstly I'm not sure how to write this and
    secondly, how do you check
    > if a text box is empty?
    Believe it or not, with the PHP function called empty();
    http://docs.php.net/manual/en/function.empty.php
    if (empty($_POST['fieldName'])) {
    // give a score of 0
    } else {
    // give a positive score
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Posting contact form to variable email address PHP

    Hi all, another one!
    I want the email address to be the hidden variable in the form below - variable higlighted in Red. What would I put for "$to ="?
    Any help would be appreciated.
    Tom
    <?php
    if (array_key_exists('send' , $_POST)) {
              // mail processing script
              // remove escape characters from POST array
    if (PHP_VERSION < 6 && get_magic_quotes_gpc()) {
      function stripslashes_deep($value) {
        $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
        return $value;
      $_POST = array_map('stripslashes_deep', $_POST);
    $to = '';
              $subject = '';
              //list expected fields
              $expected = array('name', 'email', 'comments');
              //set required fields
              $required = array('name', 'comments');
              //create empty array for any missing fields
              $missing = array();
              // assume that there is nothing suspect
              $suspect = false;
              // create a pattern to locate suspect phrases
              $pattern = '/Content-Type:|Bcc:|Cc:/i';
                // function to check for suspect phrases
      function isSuspect($val, $pattern, &$suspect) {
        // if the variable is an array, loop through each element
              // and pass it recursively back to the same function
              if (is_array($val)) {
          foreach ($val as $item) {
                  isSuspect($item, $pattern, $suspect);
                } else {
          // if one of the suspect phrases is found, set Boolean to true
                if (preg_match($pattern, $val)) {
            $suspect = true;
              // check  the $_POST array and any subarrays for suspect content
              isSuspect($_POST, $pattern, $suspect);
              if ($suspect) {
                        $mailSent = false;
                        unset($missing);
              } else {
              //proces the $_POST Variables
              foreach ($_POST as $key => $value) {
                        //assign temporary variable and strip whitespace if not an array
                        $temp = is_array($value) ? $value: trim($value);
                        //if empty and required, add to $missing array
                        if (empty($temp) && in_array($key, $required)) {
                                  array_push($missing, $key);
                        } elseif (in_array($key, $expected)) {
                                  //otherwise, assign to a variable of the same name as $key
                                  ${$key} = $temp;
              // validate the email address
      if (!empty($email)) {
        // regex to identify illegal characters in email address
        $checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
              // reject the email address if it doesn't match
        if (!preg_match($checkEmail, $email)) {
          $suspect = true;
          $mailSent = false;
          unset($missing);
              //go ahead ONLY if not suspect and all required fields OK
              if (!$suspect && empty($missing)) {
              // build the message
              $message = "Name: $name\r\n\r\n";
              $message .= "Email: $email\r\n\r\n";
              $message .= "Message: $comments\r\n\r\n";
              //limit line length to 70 characters
              $message = wordwrap($message, 70);
              //Create aditional headers
              $headers = "From: Website Enquiry\r\n";
              $headers .= 'Content-Type: text/plain; charset=utf-8';
              if (!empty($email)) {
              $headers .= "\r\nReply-To: $email";
              //send it
              $mailSent = mail($to, $subject, $message, $headers);
              if ($mailSent) {
                        //$missing is no longer needed if the email is sent, so unset it
                        unset($missing);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <?php
    if ($_POST && $mailSent) { ?>
    <META HTTP-EQUIV="Refresh" CONTENT="5;URL=index.php">
    <?php } ?>
    <title></title>
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <link href="style/style.css" rel="stylesheet" type="text/css" />
    <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-11804201-5']);
      _gaq.push(['_trackPageview']);
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    </script>
    </head>
    <body<?php if ($_POST && $mailSent){ ?> onLoad="redirect()"<?php } ?>>
    <img src="images/photography/background.jpg" alt="Jack Wilesmith Furniture Design" class="bg" id="bg" />
    <div id="container">
      <div id="Header">
      </div>
      <div id="content">
    <?php
    if ($_POST && isset($missing) && !empty($missing)) {
              ?>
        <p class="warning"><strong>Please complete the missing item(s) indicated.</strong></p><br />
        <?php
    } elseif ($_POST && !$mailSent) {
              ?>
        <p class="warning"><strong>Sorry, there was a problem sending your message, please try again later. </strong></p><br />
              <?php
    } elseif ($_POST && $mailSent) {
              ?>
        <p><strong>Your Message has been sent succesfully - <strong>You will be redirected in 5 seconds</strong></strong></p><br />
    <SCRIPT LANGUAGE="JavaScript"><!--
    function redirect () { setTimeout("go_now()",5000); }
    function go_now ()   { window.location.href = "index.php"; }
    //--></SCRIPT>
        <?php } ?>
        <form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
        <p>
          <label for="name">Name:</label><br />
          <input name="name" type="text" class="textInput" id="name"
          <?php if (isset($missing)) {
    echo 'value="' . htmlentities($_POST['name'], ENT_COMPAT, 'UTF-8') . '"';
    ?>
          /> <?php
                if (isset($missing) && in_array('name', $missing)) {?> <span class="warning">Please enter your name</span><?php } ?>
        </p><br />
        <p>
          <label for="email">Email:</label><br />
          <span id="sprytextfield1">
          <input name="email" type="text" class="textInput" id="email"
          <?php if (isset($missing)) {
    echo 'value="' . htmlentities($_POST['email'], ENT_COMPAT, 'UTF-8') . '"';
    ?>
          />
    <span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
          <?php
                if (isset($missing) && in_array('email', $missing)) {?> <span class="warning">Please enter your Email Address</span><?php } ?>
        </p><br />
        <legend></legend>
        <p>
          <label for="comments">Message:</label><br />
          <textarea name="comments" id="comments" cols="45" rows="5"><?php if (isset($missing)) {
                        echo htmlentities($_POST['comments'], ENT_COMPAT, 'UTF-8');
                } ?></textarea><?php
                if (isset($missing) && in_array('comments', $missing)) {?> <span class="warning">Please enter a Message</span><?php } ?>
        </p><br />
        <p class="clearIt">
          <input name="send" type="submit" id="send" value="Send message" />
        </p>
         <input name="email" type="hidden" id="email" value="[email protected]" />
    </form>
    </div>
    </div>
    <script type="text/javascript">
    <!--
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "email", {isRequired:false, hint:"[email protected]"});
    //-->
    </script>
    </body>
    </html>

    Lovely, simple but beautiful!
    Thanks for that.
    T

  • Convert PHP Email Code to Using SMTP Authentication

    One of my contact forms no longer is able to send (it used to until some server updates were made), for it keeps posting the following error:
    Warning:  mail() [function.mail]: SMTP server response: 501 5.1.7 Invalid address in C:\contact.php on line 71
    This form does work on three other servers, so obviously the form is in working order but not on this particular server.
    I was recommended to "set the PHP script up to log in to       the SMTP server" using this example:
    http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm
    I've only gotten this far and cannot figure out how to actually create it to SEND:
    <?php
    // set flag to indicate whether mail has been sent
    $mailSent = false;
    if (array_key_exists('eList', $_POST)) {
        // mail processing script
        // remove escape characters from POST array
        if (get_magic_quotes_gpc()) {
        function stripslashes_deep($value) {
        $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
        return $value;
          $_POST = array_map('stripslashes_deep', $_POST);
    $email = $_POST['email'];
            // check for valid email address
        $pattern = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
        if (!preg_match($pattern, trim($email))) {
        $error['email'] = 'Please enter a valid email address';
    // validate the input, beginning with name
        $name = trim($_POST['name']);
        if (empty($name)) {
            $error['name'] = 'Please enter your First Name';
        $lname = trim($_POST['lname']);
        if (empty($lname)) {
            $error['lname'] = 'Please enter your Last Name';
        $department = $_POST['department'];
        if ($_POST['department'] == '') {
        $error['department'] = 'Please select a Department';
    //     check the content of the text area
            $messageBody = trim($_POST['message']);
            if (empty($messageBody)) {
            $error['message'] = 'Please enter your message';
        // initialize variables
        if (!empty($_POST['url'])) {
        $to = '[email protected]';//
        $subject = 'Suspected as SPAM';
        $host = 'smptout.serverserver.net';
        $username = 'username';
        $password = 'password';
        } else {
        $to = '[email protected]';//
        $subject = 'Here we are';
        $host = 'smptout.serverserver.net';
        $username = 'username';
        $password = 'password';
            $SpamErrorMessage = "No URLs permitted";
        if (preg_match("/http/i", "$name")) {echo "$SpamErrorMessage"; exit();}
        if (preg_match("/http/i", "$lname")) {echo "$SpamErrorMessage"; exit();}
        if (preg_match("/http/i", "$email")) {echo "$SpamErrorMessage"; exit();}
        if (preg_match("/http/i", "$messageBody")) {echo "$SpamErrorMessage"; exit();} // check for spam
        //build the message
        $smtp = Mail::factory('smtp',
                                                                                                array('host' => $host,
                                                                                                                        'auth' => true,
                                                                                                                        'username' => $username,
                                                                                                                        'password' => $password));
        $message = "To: $department\r\n\r\n";
        $message .= "From: $name $lname\r\n";
        $message .= "$email\r\n\r\n";
        $message .= "Question/Comment: $messageBody";
        //build the additional headers
        $additionalHeaders = "From: Contact <[email protected]>\r\n";
        $additionalHeaders .= "Reply-To: $email";
    //send the email if there are not errors
        if (!isset($error)) {
        $mailSent = mail($to, $subject, $message, $additionalHeaders);
        // check that the mail was sent successfully
        if (!$mailSent) {
            $error['notSent'] = 'Sorry, there was a problem sending your mail. Please try later.';
    ?>
    Thank you for your help!

    Anyone?

  • Problem with PHP not working and Extra space in form I can't get rid of

    This is my first time doing a form, much less using php. I would appreciate your help on the problems below.
    1. in the form when you go to the website there is too much vertical spacing between the form fields.
    2.the Message field has script inside that vistors can see.
    3. on hitting the submit button it redirects me to a blank page and not the thankyou.html page that I had created.
    4. the form doesn't send the email to [email protected]
    Website URL: http://stickmancustoms.com/contact.html
    <!-- FORM CODE STARTS HERE -->
    <?php session_start(); ?>
    <?php
    if (array_key_exists('submit', $_POST)) {
        // check name field
    $name = trim($_POST['name']);
    if (empty($name)) {
        $error['name'] = 'Please provide your first name';
    elseif ($name == 'Please provide your first name') {
        $error['name'] = '';
    $_SESSION['name'] = $_POST['name'];
    // check phone field
    $phone = trim($_POST['phone']);
    if (empty($phone)) {
        $error['phone'] = 'Please provide your last name';
    elseif ($phone == 'Please provide your last name') {
        $error['phone'] = '';
    $_SESSION['phone'] = $_POST['phone'];
    // check email field
    $email = trim($_POST['email']);
    if (empty($email)) {
        $error['email'] = 'Please enter your email address';
    elseif ($email == 'Please enter your email address') {
        $error['email'] = '';
    $_SESSION['email'] = $_POST['email'];
    // check enquiry field
    $message = trim($_POST['message']);
    if (empty($message)) {
        $error['message'] = 'Please enter your message details';
    elseif ($message == 'Please enter your message details') {
        $error['message'] = '';
    $_SESSION['message'] = $_POST['message'];
    if (!empty($_POST['ufo'])) { return false; }
    // recipient
    $to = "[email protected]"; //email address -- change to your own email address
    // email subject
    $subject = "I am interested in your services, please contact me";
    // sender
    $sender = "From: ".$_POST['email']."\r\n";
    // build message
    $enquiry = "First Name: $name\n\n";
    $enquiry .= "Last Name: $phone\n\n";
    $enquiry .= "Email Address: $email\n\n";
    $enquiry .= "Message: $message\n\n";
    // send email if no form erorrs
    if (!isset($error)) {
    mail($to, $subject, $enquiry, $sender);
    header("Location: thankyou.html");        //Redirect page -- change to your own page
    ?>
    CONTACT WEB PAGE CODE BELOW
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="auto repair, accident damage, custom paint, customization, car repair, paint job, hot rod, motorcycle, cycle, bike, chopper"
    content="At StickMan Customs we give personal service with a smile. With more than 20 years experience in auto repair and customization you can be confident that we will meet your expectations and beyond. " />
    <meta name="google-site-verification" content="-41pB0MQUYT1Vbv1SId8WcU2lqEmFf0u23Sl3NY24CE" />
    <title>Stickman Customs</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link href="smc.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    <!--
    a:visited {
        color: #F4781E;
    -->
    </style>
    </head>
    <body bgcolor="#000000">
    <table width="936" height="200" border="0" align="center">
      <tr>
        <td height="196" valign="top"><p class="style1"><a href="index.html" target="_self"><a href="index.html" target="_self"><img src="images/smcbanner.jpg" width="936" height="194" border="0" usemap="#Map" /></a>
            <map name="Map" id="Map">
              <area shape="rect" coords="97,7,289,190" href="index.html" target="_self" />
              <area shape="rect" coords="290,156,380,189" href="about.html" target="_self" />
              <area shape="rect" coords="396,159,550,190" href="repair.html" target="_self" />
              <area shape="rect" coords="561,159,619,190" href="cars.html" target="_self" />
              <area shape="rect" coords="627,159,703,188" href="cycles.html" target="_self" />
              <area shape="rect" coords="711,160,885,190" href="projects.html" target="_self" />
              <area shape="rect" coords="734,23,917,78" href="contact.html" target="_self" />
              <area shape="rect" coords="786,175,787,176" href="#" />
            </map>
          </p>
          <table width="936" border="0" align="center" cellpadding="5" cellspacing="5">
            <tr>
              <td width="512" height="450" valign="top"><p class="Headers"><img src="images/car1.jpg" width="432" height="432" /></p></td>
              <td width="389" height="450" valign="top"><form id="enquiryForm" name="enquiryForm" method="post" action="contact.php">
                  <h1><span class="BodyBold">Contact Us </span></h1>
                  <h1> <span class="BodyCopy">*Required Information </span></h1>
                  <h1><span class="BodyBold">
                    <label for="Name">Name* </label>
                    </span>
                    <input type="text" name="name" id="name" <?php if(isset($error['first_name'])) echo "style='border: 1px solid #C00; color: #C00;'"; ?> value="<?php if(isset($name)) {echo $name;} ?><?php if(isset($error['first_name'])) echo $error['name']; ?>" onfocus="this.value=''" />
                  </h1>
                  <p>
                    <label for="Name" class="BodyBold">Phone* </label>
                    <input type="text" name="phone" id="phone" <?php if(isset($error['phone'])) echo "style='border: 1px solid #C00; color: #C00;'"; ?> value="<?php if(isset($phone)) {echo $phone;} ?><?php if(isset($error['phone'])) echo $error['phone']; ?>" onfocus="this.value=''" />
                  <p>
                    <label for="email" class="BodyBold">Email* </label>
                    <input type="text" name="email" id="email" <?php if(isset($error['email'])) echo "style='border: 1px solid #C00; color: #C00;'"; ?> value="<?php if(isset($email)) {echo $email;} ?><?php if(isset($error['email'])) echo $error['email']; ?>" onfocus="this.value=''" />
                  <p style="padding-bottom: 0;">
                    <label for="enquiry" class="BodyBold">Message*</label>
                    <br />
                    <textarea name="message" id="message" <?php if(isset($error['message'])) echo "style='border: 1px solid #C00; color: #C00;'"; ?> onfocus="this.value=''"><?php if(isset($message)) {echo $message;} ?><?php if(isset($error['message'])) echo $error['message']; ?>
              </textarea>
                  </p>
                  <p>
                    <input type="text" name="ufo" style="display: none;" />
                    <input type="submit" id="submitButton" name="submit" value="Submit" />
                  </p>
    </form></td>
            </tr>
          </table></td>
      </tr>
    </table>
    <table width="936" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><div align="center">
            <div align="center" class="bottomlinks">
              <p><a href="about.html" target="_self"><br />
                ABOUT US <img src="images/space.jpg" alt="s" width="18" height="7" border="0" /></a>| <a href="index.html" target="_self"><img src="images/space.jpg" alt="s" width="18" height="7" border="0" /></a><a href="repair.html" target="_self">ACCIDENT REPAIR</a><a href="index.html" target="_self"><img src="images/space.jpg" alt="s" width="18" height="7" border="0" /></a>| <a href="index.html" target="_self"><img src="images/space.jpg" alt="s" width="18" height="7" border="0" /></a><a href="cars.html" target="_self">CARS</a><a href="index.html" target="_self"><img src="images/space.jpg" alt="s" width="18" height="7" border="0" /></a>| <a href="index.html" target="_self"><img src="images/space.jpg" alt="s" width="18" height="7" border="0" /></a><a href="cycles.html" target="_self">CYCLES</a><a href="index.html" target="_self"><img src="images/space.jpg" alt="s" width="18" height="7" border="0" /></a>| <a href="index.html" target="_self"><img src="images/space.jpg" alt="s" width="18" height="7" border="0" /></a><a href="projects.html" target="_self">SPECIAL PROJECTS</a></p>
              <p class="Address_Text">StickMan Customs<br />
                800 Mooresville Rd, Kannapolis, NC 28081<br />
                704.699.5110 </p>
            </div>
            <p class="style74"><span class="atb_text">Designed &amp; Hosted by</span><br />
              <a href="http://www.abovethebarrdesign.com" target="_self"><img src="images/atbd.jpg" alt="1" width="155" height="77" border="0" /></a><br />
            </p>
          </div></td>
      </tr>
    </table>
    </body>
    </html>
    <!-- text below generated by server. PLEASE REMOVE -->
    <!-- Counter/Statistics data collection code -->
    <script language="JavaScript" src="http://us.js2.yimg.com/us.js.yimg.com/lib/smb/js/hosting/cp/js_source/whv2_001.js" type="text/javascript"></script>
    <script language="JavaScript" type="text/javascript">geovisit();</script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <noscript>
    <img src="http://visit.webhosting.yahoo.com/visit.gif?us1262644054" alt="setstats" border="0" width="1" height="1" />
    </noscript>
    </html>

    The below should work for you.
    As Jon points out the page has to be a .php page NOT a .html page.
    The idea is that the page gets sent back to itself and the form information is processed then sent to the email address if there are no errors detected.
    The unusual gaps in the form were being caused by unclosed tags amongst other things - hopefuly I put some of it right for you.
    Copy all of the below and save it as contact.php - Obviously your server needs to support php for it to work, most do. I have not specified your email address in the php as it attracts spam from the forum so re-instate it where the xxxxxxx are.
    <?php
    if (array_key_exists('submit', $_POST)) {
    // check name field
    $name = trim($_POST['name']);
    if (empty($name)) {
    $error['name'] = 'Please provide your name';
    elseif ($name == 'Please provide your name') {
    $error['name'] = '';
    // check phone field
    $phone = trim($_POST['phone']);
    if (empty($phone)) {
    $error['phone'] = 'Please provide your phone number';
    elseif ($phone == 'Please provide your phone number') {
    $error['phone'] = '';
    // check email field
    $email = trim($_POST['email']);
    if (empty($email)) {
    $error['email'] = 'Please enter your email address';
    elseif ($email == 'Please enter your email address') {
    $error['email'] = '';
    // check enquiry field
    $message = trim($_POST['message']);
    if (empty($message)) {
    $error['message'] = 'Please enter your message details';
    elseif ($message == 'Please enter your message details') {
    $error['message'] = '';
    if (!empty($_POST['ufo'])) { return false; }
    // recipient
    $to = "xxxxxx@xxxxxxxxxxxxxx"; //email address -- change to your own email address
    // email subject
    $subject = "I am interested in your services, please contact me";
    // sender
    $sender = "From: ".$_POST['email']."\r\n";
    // build message
    $enquiry = "Name: $name\n\n";
    $enquiry .= "Phone Number: $phone\n\n";
    $enquiry .= "Email Address: $email\n\n";
    $enquiry .= "Message: $message\n\n";
    // send email if no form erorrs
    if (!isset($error)) {
    mail($to, $subject, $enquiry, $sender);
    header("Location: thankyou.html");  //Redirect page -- change to your own page
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="auto repair, accident damage, custom paint, customization, car repair, paint job, hot rod, motorcycle, cycle, bike, chopper"
    content="At StickMan Customs we give personal service with a smile. With more than 20 years experience in auto repair and customization you can be confident that we will meet your expectations and beyond. " />
    <meta name="google-site-verification" content="-41pB0MQUYT1Vbv1SId8WcU2lqEmFf0u23Sl3NY24CE" />
    <title>Stickman Customs</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link href="http://stickmancustoms.com/smc.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    <!--
    a:visited {
        color: #F4781E;
    -->
    </style>
    </head>
    <body bgcolor="#000000">
    <table width="936" height="200" border="0" align="center">
      <tr>
        <td height="196" valign="top"><p class="style1"><a href="index.html" target="_self"><a href="index.html" target="_self"><img src="http://stickmancustoms.com/images/smcbanner.jpg" width="936" height="194" border="0" usemap="#Map" /></a>
            <map name="Map" id="Map">
              <area shape="rect" coords="97,7,289,190" href="index.html" target="_self" />
              <area shape="rect" coords="290,156,380,189" href="about.html" target="_self" />
              <area shape="rect" coords="396,159,550,190" href="repair.html" target="_self" />
              <area shape="rect" coords="561,159,619,190" href="cars.html" target="_self" />
              <area shape="rect" coords="627,159,703,188" href="cycles.html" target="_self" />
              <area shape="rect" coords="711,160,885,190" href="projects.html" target="_self" />
              <area shape="rect" coords="734,23,917,78" href="contact.html" target="_self" />
              <area shape="rect" coords="786,175,787,176" href="#" />
            </map>
          </p>
          <table width="936" border="0" align="center" cellpadding="5" cellspacing="5">
            <tr>
              <td width="512" height="450" valign="top"><p class="Headers"><img src="http://stickmancustoms.com/images/car1.jpg" width="432" height="432" /></p></td>
              <td width="389" height="450" valign="top"><form id="enquiryForm" name="enquiryForm" method="post" action="contact.php">
                  <p><span class="BodyBold">Contact Us </span></p>
                  <p><span class="BodyCopy">*Required Information</span></p>
                  <p>
                    <label for="Name" class="BodyBold">Name* </label>
                    </span>
                    <input type="text" name="name" id="name" <?php if(isset($error['name'])) echo "style='border: 1px solid #C00; color: #C00;'"; ?> value="<?php if(isset($name)) {echo $name;} ?><?php if(isset($error['name'])) echo $error['name']; ?>" onfocus="this.value=''" />
                  </p>
                  <p>
                    <label for="Name" class="BodyBold">Phone* </label>
                    <input type="text" name="phone" id="phone" <?php if(isset($error['phone'])) echo "style='border: 1px solid #C00; color: #C00;'"; ?> value="<?php if(isset($phone)) {echo $phone;} ?><?php if(isset($error['phone'])) echo $error['phone']; ?>" onfocus="this.value=''" />
                  </p>
                  <p>
                    <label for="email" class="BodyBold">Email* </label>
                    <input type="text" name="email" id="email" <?php if(isset($error['email'])) echo "style='border: 1px solid #C00; color: #C00;'"; ?> value="<?php if(isset($email)) {echo $email;} ?><?php if(isset($error['email'])) echo $error['email']; ?>" onfocus="this.value=''" />
                    </p>
                  <p>
                    <label for="enquiry" class="BodyBold">Message*</label>
                    <textarea name="message" id="message" <?php if(isset($error['message'])) echo "style='border: 1px solid #C00; color: #C00;'"; ?> onfocus="this.value=''"><?php if(isset($message)) {echo $message;} ?><?php if(isset($error['message'])) echo $error['message']; ?>
              </textarea>
                  </p>
                  <p>
                    <input type="text" name="ufo" style="display: none;" />
                    <input type="submit" id="submitButton" name="submit" value="Submit" />
                  </p>
    </form></td>
            </tr>
          </table></td>
      </tr>
    </table>
    <table width="936" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><div align="center">
            <div align="center" class="bottomlinks">
              <p><a href="about.html" target="_self">
                ABOUT US <img src="http://stickmancustoms.com/images/space.jpg" alt="s" width="18" height="7" border="0" /></a>| <a href="index.html" target="_self"><img src="http://stickmancustoms.com/images/space.jpg" alt="s" width="18" height="7" border="0" /></a><a href="repair.html" target="_self">ACCIDENT REPAIR</a><a href="index.html" target="_self"><img src="http://stickmancustoms.com/images/space.jpg" alt="s" width="18" height="7" border="0" /></a>| <a href="index.html" target="_self"><img src="http://stickmancustoms.com/images/space.jpg" alt="s" width="18" height="7" border="0" /></a><a href="cars.html" target="_self">CARS</a><a href="index.html" target="_self"><img src="http://stickmancustoms.com/images/space.jpg" alt="s" width="18" height="7" border="0" /></a>| <a href="index.html" target="_self"><img src="http://stickmancustoms.com/images/space.jpg" alt="s" width="18" height="7" border="0" /></a><a href="cycles.html" target="_self">CYCLES</a><a href="index.html" target="_self"><img src="http://stickmancustoms.com/images/space.jpg" alt="s" width="18" height="7" border="0" /></a>| <a href="index.html" target="_self"><img src="http://stickmancustoms.com/images/space.jpg" alt="s" width="18" height="7" border="0" /></a><a href="projects.html" target="_self">SPECIAL PROJECTS</a></p>
              <p class="Address_Text">StickMan Customs<br />
                800 Mooresville Rd, Kannapolis, NC 28081<br />
                704.699.5110 </p>
            </div>
            <p class="style74"><span class="atb_text">Designed &amp; Hosted by</span><br />
              <a href="http://www.abovethebarrdesign.com" target="_self"><img src="http://stickmancustoms.com/images/atbd.jpg" alt="1" width="155" height="77" border="0" /></a><br />
            </p>
          </div></td>
      </tr>
    </table>
    </body>
    </html>
    <!-- text below generated by server. PLEASE REMOVE -->
    <!-- Counter/Statistics data collection code -->
    <script language="JavaScript" src="http://us.js2.yimg.com/us.js.yimg.com/lib/smb/js/hosting/cp/js_source/whv2_001.js" type="text/javascript"></script>
    <script language="JavaScript" type="text/javascript">geovisit();</script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <noscript>
    <img src="http://visit.webhosting.yahoo.com/visit.gif?us1262644054" alt="setstats" border="0" width="1" height="1" />
    </noscript>
    </html>

  • My  PHP  form no longer works?

    Hi
    http://www.collegestudentvoice.com/form/form.php
    1. Programmer says there is no coding errors.  Nothing has changed.
    2. Host says there must be coding errors.
    3. There may version incompetibilities with Perl script between the form and the host version.
    these are 3 files:
    Sendform:
    <?php
    // Pear library includes
    // You should have the pear lib installed
    include_once('Mail.php');
    include_once('Mail/mime.php');
    //Settings
    $max_allowed_file_size = 10000000; // size in KB
    $allowed_extensions = array("jpg", "jpeg", "gif", "bmp");
    $upload_folder = 'files/'; //<-- this folder must be writeable by the script
    $your_email = '[email protected]';//<<--  update this to your email address
    $errors ='';
    if(isset($_POST['submit']))
        //Get the uploaded file information
        $name_of_uploaded_file =  basename($_FILES['uploaded_file']['name']);
        //get the file extension of the file
        $type_of_uploaded_file = substr($name_of_uploaded_file,
                                strrpos($name_of_uploaded_file, '.') + 1);
        $size_of_uploaded_file = $_FILES["uploaded_file"]["size"]/1024;
        ///------------Do Validations-------------
        if(empty($_POST['name'])||empty($_POST['email']))
            $errors .= "\n Name and Email are required fields. ";   
        if(IsInjected($visitor_email))
            $errors .= "\n Bad email value!";
        if($size_of_uploaded_file > $max_allowed_file_size )
            $errors .= "\n Size of file should be less than $max_allowed_file_size";
        //------ Validate the file extension -----
        $allowed_ext = false;
        for($i=0; $i<sizeof($allowed_extensions); $i++)
            if(strcasecmp($allowed_extensions[$i],$type_of_uploaded_file) == 0)
                $allowed_ext = true;       
        if(!$allowed_ext)
            $errors .= "\n The uploaded file is not supported file type. ".
            " Only the following file types are supported: ".implode(',',$allowed_extensions);
        //send the email
        if(empty($errors))
            //copy the temp. uploaded file to uploads folder
            $path_of_uploaded_file = $upload_folder . $name_of_uploaded_file;
            $tmp_path = $_FILES["uploaded_file"]["tmp_name"];
            if(is_uploaded_file($tmp_path))
                if(!copy($tmp_path,$path_of_uploaded_file))
                    $errors .= '\n error while copying the uploaded file';
            //send the email
            $name = $_POST['name'];
            $visitor_email = $_POST['email'];
            $user_message = $_POST['message'];
            $to = $your_email;
            $subject="New form submission";
            $from = $your_email;
            $text = "A user  $name has sent you this message:\n $user_message";
            $message = new Mail_mime();
            $message->setTXTBody($text);
            $message->addAttachment($path_of_uploaded_file);
            $body = $message->get();
            $extraheaders = array("From"=>$from, "Subject"=>$subject,"Reply-To"=>$visitor_email);
            $headers = $message->headers($extraheaders);
            $mail = Mail::factory("mail");
            $mail->send($to, $headers, $body);
            //redirect to 'thank-you page
            header('Location: thank-you.html');
    ///////////////////////////Functions/////////////////
    // Function to validate against any email injection attempts
    function IsInjected($str)
      $injections = array('(\n+)',
                  '(\r+)',
                  '(\t+)',
                  '(%0A+)',
                  '(%0D+)',
                  '(%08+)',
                  '(%09+)'
      $inject = join('|', $injections);
      $inject = "/$inject/i";
      if(preg_match($inject,$str))
        return true;
      else
        return false;
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
        <title>File upload form</title>
    <!-- define some style elements-->
    <style>
    label,a, body
        font-family : Arial, Helvetica, sans-serif;
        font-size : 12px;
    </style>   
    <!-- a helper script for vaidating the form-->
    <script language="JavaScript" src="scripts/gen_validatorv31.js" type="text/javascript"></script>   
    </head>
    <body>
    <?php
    if(!empty($errors))
        echo nl2br($errors);
    ?>
    <form method="POST" name="email_form_with_php"
    action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" enctype="multipart/form-data">
    <p>
    <label for='name'>Name: </label><br>
    <input type="text" name="name" >
    </p>
    <p>
    <label for='email'>Email: </label><br>
    <input type="text" name="email" >
    </p>
    <p>
    <label for='message'>Message:</label> <br>
    <textarea name="message"></textarea>
    </p>
    <p>
    <label for='uploaded_file'>Select A File To Upload:</label> <br>
    <input type="file" name="uploaded_file">
    </p>
    <input type="submit" value="Submit" name='submit'>
    </form>
    <script language="JavaScript">
    // Code for validating the form
    // Visit http://www.javascript-coder.com/html-form/javascript-form-validation.phtml
    // for details
    var frmvalidator  = new Validator("email_form_with_php");
    frmvalidator.addValidation("name","req","Please provide your name");
    frmvalidator.addValidation("email","req","Please provide your email");
    frmvalidator.addValidation("email","email","Please enter a valid email address");
    </script>
    <noscript>
    <small><a href='http://www.html-form-guide.com/email-form/php-email-form-attachment.html'
    >How to attach file to email in PHP</a> article page.</small>
    </noscript>
    </body>
    </html>
    FORM:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>College Student</title>
    <link rel="stylesheet" type="text/css" href="css/view.css" media="all">
    <script type="text/javascript" src="js/view.js"></script>
    <script src="js/forms.js" type="text/javascript"></script>
    </head>
    <body id="main_body" >
        <div id="form_container">
    <form action="formaction.php" method="post" enctype="multipart/form-data" name="contactus" id="contactus"  style="border:none;" onsubmit="return validateForm()">
                        <div class="form_description">
                <h2><img src="CSVlogo.GIF" width="269" height="97" alt="Logo" /></h2>
                <p>Please type in your first and last names along with our school email address (i.e., [email protected]) when submitting your articles or photographs.</p>
    <p>Select the category that best describes the subject of  your article or photograph. (i.e., Business, Politics, Sports, Humor, etc.)</p>
    <p>When writing about a sporting event please include the name of the sport in the ‘Subject’ line of your email along with the date of the event and the names of the teams. (i.e., Basketball 01-15-11 L.A. Lakers vs.Detroit Pistons)</p>
            </div>       
            <div>
                    <?php
    if (isset($_GET['suc'])) {
    echo "<div style='color:#F00; padding:15px; display:block; margin:10px 0 10px 0;'> ";
    echo "Thank you for your submission!";
    echo "</div>";
    } else {
    ?>
    </div>
                <ul >
                        <li id="li_5" >
            <label class="description" for="Business">Business </label>
            <div>
            <select class="element select medium" name="Business">
                <option value="" selected="selected"></option>
    <option value="Classified" >Classified</option>
    <option value="careertips" >Career Tip</option>
            </select>
            </div>
            </li>        <li id="li_6" >
            <label class="description" for="ProfessionalSports">Professional Sports </label>
            <div>
            <select class="element select medium" name="ProfessionalSports">
                <option value="" selected="selected"></option>
    <option value="NBA" >NBA</option>
    <option value="NFL" >NFL</option>
    <option value="MLB" >MLB</option>
    <option value="otherprosports" >Other</option>
            </select>
            </div>
            </li>        <li id="li_7" >
            <label class="description" for="Humor101">Humor 101</label>
            <div>
            <select class="element select medium" name="Humor101">
                <option value="" selected="selected"></option>
    <option value="Cartoons" >Cartoons</option>
    <option value="Jokes" >Jokes</option>
    <option value="Stories" >Stories</option>
    <option value="Photographs" >Photographs</option>
            </select>
            </div>
            </li>        <li id="li_8" >
            <label class="description" for="CollegeSports">College Sports</label>
            <div>
            <select class="element select medium" name="CollegeSports">
                <option value="" selected="selected"></option>
    <option value="basketballcollege" >Basketball</option>
    <option value="baseballcollege" >Baseball</option>
    <option value="Footballcollege" >Football</option>
    <option value="Softball" >Softball</option>
    <option value="othercollege" >Other</option>
            </select>
            </div>
            </li>        <li id="li_9" >
            <label class="description" for="Politics">Politics</label>
            <div>
            <select class="element select medium" name="Politics">
                <option value="" selected="selected"></option>
    <option value="statelocal" >State/Local</option>
    <option value="National" >National</option>
    <option value="World" >World</option>
            </select>
            </div>
            </li>        <li id="li_1" >
            <label class="description" for="element_1">Name </label>
            <span>
                <input id="First" name="First" class="element text" maxlength="255" size="40" value=""/>
                <label>First</label>
            </span>
            <span>
                <input id="Last" name= "Last" class="element text" maxlength="255" size="40" value=""/>
                <label>Last</label>
            </span>
            </li>       
            <li id="li_sub" >
            <label class="description" for="Subject">Subject </label>
            <div>
                <input id="Subject" name="Subject" class="element text medium required" type="text" maxlength="255" value=""/>
            </div>
            </li>   
            <li id="li_2" >
            <label class="description" for="Email">Email </label>
            <div>
                <input id="Email" name="Email" class="element text medium required email" type="text" maxlength="255" value=""/>
            </div>
            </li>        <li id="li_3" >
            <label class="description" for="EmailC">Confirm Email </label>
            <div>
                <input id="EmailC" name="EmailC" class="element text medium" type="text" maxlength="255" value=""/>
            </div>
            </li>        <li id="li_4" >
            <label class="description" for="Suggestions">Suggestions </label>
            <div>
                <textarea id="Suggestions" name="Suggestions" class="element textarea medium"></textarea>
            </div>
            </li>
          <li id="li_5" >
            <label class="description" for="Upload">Upload File </label>
    <input type="file" name="uploaded_file">
            <div>
              </div>
            </li>
            <li id="li_6" >
            <label class="description" for="Upload">Are you human?</label>
            <?php
            require_once('recaptchalib.php');
              $publickey = "6LfwwsISAAAAAA7UTKJcDATLiK-e55gPFW1Opfrq"; // you got this from the signup page
              echo recaptcha_get_html($publickey);
            ?>
            <div>
              </div>
            </li>
                        <li class="buttons">
                    <input type="submit" name="Submit" value="Submit" class="button" />
    </li>
                </ul>
    </form>
    <!--        <div id="footer">
            </div>
    -->    </div>
    </body>
    </html>
    FORMACTION
    <?php
      require_once('recaptchalib.php');
    $privatekey = "6LfwwsISAAAAAAPShkJ6nV3qkgLDHCe2uXj9RTWw";
      $resp = recaptcha_check_answer ($privatekey,
                                    $_SERVER["REMOTE_ADDR"],
                                    $_POST["recaptcha_challenge_field"],
                                    $_POST["recaptcha_response_field"]);
      if (!$resp->is_valid) {
        die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
      else {
    include_once('Mail.php');
    include_once('Mail/mime.php');
    $errors ='';
    $max_allowed_file_size = 10000000; // size in KB
    $allowed_extensions = array("jpg", "jpeg", "gif", "bmp");
    $upload_folder = 'files/';
        $name_of_uploaded_file =  basename($_FILES['uploaded_file']['name']);
        $type_of_uploaded_file = substr($name_of_uploaded_file,
                                strrpos($name_of_uploaded_file, '.') + 1);
        $size_of_uploaded_file = $_FILES["uploaded_file"]["size"]/1024;
        if($size_of_uploaded_file > $max_allowed_file_size )
            $errors .= "\n Size of file should be less than $max_allowed_file_size";
        $allowed_ext = false;
        for($i=0; $i<sizeof($allowed_extensions); $i++)
            if(strcasecmp($allowed_extensions[$i],$type_of_uploaded_file) == 0)
                $allowed_ext = true;       
        if(!$allowed_ext)
            $errors .= "\n The uploaded file is not supported file type. ".
            " Only the following file types are supported: ".implode(',',$allowed_extensions);
        if(empty($errors))
            $path_of_uploaded_file = $upload_folder . $name_of_uploaded_file;
            $tmp_path = $_FILES["uploaded_file"]["tmp_name"];
            if(is_uploaded_file($tmp_path))
                if(!copy($tmp_path,$path_of_uploaded_file))
                    $errors .= '\n error while copying the uploaded file';
            $Business = Trim(stripslashes($_POST['Business']));
            $ProfessionalSports = Trim(stripslashes($_POST['ProfessionalSports']));
            $Humor101 = Trim(stripslashes($_POST['Humor101']));
            $CollegeSports = Trim(stripslashes($_POST['CollegeSports']));
            $Politics = Trim(stripslashes($_POST['Politics']));
            $EmailToBusiness = $Business . "@collegestudentvoice.net";
            $EmailToProfessionalSports = $ProfessionalSports . "@collegestudentvoice.net";
            $EmailToHumor101 =  $Humor101 ."@collegestudentvoice.net";
            $EmailToCollegeSports = $CollegeSports . "@collegestudentvoice.net";
            $EmailToPolitics = $Politics . "@collegestudentvoice.net";
            $EmailTo = "[email protected]";
            $EMailSubject = Trim(stripslashes($_POST['Subject']));
            $First = Trim(stripslashes($_POST['First']));
            $Last = Trim(stripslashes($_POST['Last']));
            $Email = Trim(stripslashes($_POST['Email']));
            $Suggestions = Trim(stripslashes($_POST['Suggestions']));
            $Body = "The following form has been filled";
            $Body .= "\n";
            $Body .= "---------------------------------------------------------------------------------";
            $Body .= "\n";
            $Body .= "\n";
            $Body .= "First Name: ";
            $Body .= $First;
            $Body .= "\n";
            $Body .= "Last Name: ";
            $Body .= $Last;
            $Body .= "\n";
            $Body .= "Email: ";
            $Body .= $Email;
            $Body .= "\n";
            $Body .= "Business: ";
            $Body .= $Business;
            $Body .= "\n";
            $Body .= "Professional Sports: ";
            $Body .= $ProfessionalSports;
            $Body .= "\n";
            $Body .= "Humor 101: ";
            $Body .= $Humor101;
            $Body .= "\n";
            $Body .= "College Sports: ";
            $Body .= $CollegeSports;
            $Body .= "\n";
            $Body .= "Politics: ";
            $Body .= $Politics;
            $Body .= "\n";
            $Body .= "Suggestions: ";
            $Body .= $Suggestions;
            $Body .= "\n";
            $Body .= "\n";
            $Body .= "---------------------------------------------------------------------------------\n";
            $Body .= "Emails sent to: " . strtolower($EmailToBusiness) . " / " .strtolower($EmailToProfessionalSports). " / " .strtolower($EmailToHumor101). " / " .strtolower($EmailToCollegeSports). " / ".strtolower($EmailToPolitics). "";
            $to = "[email protected]";
            $subject= $EMailSubject;
            $from = "[email protected]";
            $text = "\n $Body";
            $message = new Mail_mime();
            $message->setTXTBody($text);
            $message->addAttachment($path_of_uploaded_file);
            $body = $message->get();
            $extraheaders = array("From"=>$from, "Subject"=>$subject,"Reply-To"=>$Email);
            $headers = $message->headers($extraheaders);
            $mail = Mail::factory("mail");
            $mail->send($to, $headers, $body);
            if ($Business != "")
                        $mail->send(strtolower($EmailToBusiness), $headers, $body);
            if ($ProfessionalSports != "")
                        $mail->send(strtolower($EmailToProfessionalSports), $headers, $body);
            if ($Humor101 != "")
                        $mail->send(strtolower($EmailToHumor101), $headers, $body);
            if ($CollegeSports != "")
                        $mail->send(strtolower($EmailToCollegeSports), $headers, $body);
            if ($Politics != "")
                        $mail->send(strtolower($EmailToPolitics), $headers, $body);
            print "<meta http-equiv=\"refresh\" content=\"0;URL=form.php?suc=y\">";
    ?>

    bregent,
    you have explained everything was is happening.
    Mine firewall setttings block the scrip so when I fill the form and submit it, I do not get any errors, but that form information does not go anywhere.
    All firewall setting should be OFF  when a form is submitted?
    dreamweavewr101.1

  • I have created a working php contact file but I do not know how get it onto my website properly

    Hi,
    I don't know if this a big job or too complicated for me, but I thought I would ask anyway.
    I have a contact page www.bristolequestrianservices.co.uk/contactus.html which has never ever actually worked.  I have now spend ages and ages doing a new contact page, contact.php, and this one now works perfectly.
    My problem is now I don't know how to put it all together if that makes sense.  My contactus.html has all my other things ie, header, topnav and everything like that but the contact php is just a contact page.
    Hope all of this makes sense and don't know if anyone has the time to help me with this as I think it's most probably too much!  I'm so close but so far!
    Thanks in anticipation

    Below is the entire contact.php page. Just reinstate your email address where the XXXXXXXXXX are (I don't post email address in the forum because of spam issues.)
    I have not had chance to entirely style the form but it's near. The form css is in the page. You can move it out and into its own stylesheet. You will now have to change your contact page links in your other pages from contact.html to contact.php
    Its a lot of <divs> for a simple form. This all could have been produced with 50% less code.
    <?php
    // Set email variables
    $email_to = '[email protected]';
    $email_subject = 'Form submission';
    // Set required fields
    $required_fields = array('fullname','email','comment');
    // set error messages
    $error_messages = array(
    'fullname' => 'Please enter a Name to proceed.',
    'email' => 'Please enter a valid Email Address to continue.',
    'comment' => 'Please enter your Message to continue.'
    // Set form status
    $form_complete = FALSE;
    // configure validation array
    $validation = array();
    // check form submittal
    if(!empty($_POST)) {
    // Sanitise POST array
    foreach($_POST as $key => $value) $_POST[$key] = remove_email_injection(trim($value));
    // Loop into required fields and make sure they match our needs
    foreach($required_fields as $field) {
    // the field has been submitted?
    if(!array_key_exists($field, $_POST)) array_push($validation, $field);
    // check there is information in the field?
    if($_POST[$field] == '') array_push($validation, $field);
    // validate the email address supplied
    if($field == 'email') if(!validate_email_address($_POST[$field])) array_push($validation, $field);
    // basic validation result
    if(count($validation) == 0) {
    // Prepare our content string
    $email_content = 'New Website Comment: ' . "\n\n";
    // simple email content
    foreach($_POST as $key => $value) {
    if($key != 'submit') $email_content .= $key . ': ' . $value . "\n";
    // if validation passed ok then send the email
    mail($email_to, $email_subject, $email_content);
    // Update form switch
    $form_complete = TRUE;
    function validate_email_address($email = FALSE) {
    return (preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i', $email))? TRUE : FALSE;
    function remove_email_injection($field = FALSE) {
    return (str_ireplace(array("\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field));
    ?>
    <!DOCTYPE HTML>
    <html>
    <head>
    <script type="text/javascript" src="http://www.bristolequestrianservices.co.uk/js/jquery.js"></script>
    <script type="text/javascript" src="http://www.bristolequestrianservices.co.uk/js/timothy.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/mootools/1.3.0/mootools-yui-compressed.js"></script>
    <script type="text/javascript"  src="http://www.bristolequestrianservices.co.uk/contact/validation/validation.js"></script>
    <script type="text/javascript">
    var nameError = '<?php echo $error_messages['fullname']; ?>';
    var emailError = '<?php echo $error_messages['email']; ?>';
    var commentError = '<?php echo $error_messages['comment']; ?>';
    function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    </script>
    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
    ga('create', 'UA-47829305-1', 'bristolequestrianservices.co.uk');
    ga('send', 'pageview');
    </script>
    <link href="http://www.bristolequestrianservices.co.uk/css/styles.css" rel="stylesheet" type="text/css" media="screen">
    <link href="http://www.bristolequestrianservices.co.uk/css/print.css" rel="stylesheet" type="text/css" media="print">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Type" content="cache" />
    <meta name="robots" content="INDEX,FOLLOW" />
    <meta name="keywords" content="mobile field shelter,mobile stables,good quality,prices,cheap,shelters, shelter, stables, stables, mobile filed shelters, mobile stable, " />
    <meta name="description" content="Quality mobile stables and field shelters, we will not be beaten on price for this quality" />
    <title>Mobile Field Shelters | Mobile Stables | Bristol Equestrian Services</title>
    <!-- Google Analytics Code Goes Below Here -->
    <meta name="google-site-verification" content="zUg_yn4KVoI6Xy8LLvw0PjtwgXPmlQVNKb3tY001yp4" />
    <!-- End Google Analytics Code -->
    <style>
    #formWrap {
        width:648px;
        margin-top: 0px;
        margin-left: 0px;
        background:#fff;
        border:1px solid #F1F1F1;
        -moz-border-radius:20px;
        -moz-box-shadow:2px 2px 5px #999;
        -webkit-border-radius:20px;
        -webkit-box-shadow:2px 2px 5px #999;
        padding: 0;
    #formWrap #form {
        border-top:1px solid #EEE;
        width:648px;
    #formWrap #form .row {
        border-bottom:1px dotted #EEE;
        display:block;
        line-height:38px;
        overflow:auto;
        padding: 10px 0px;
        width:100%;  
    #form .row .label {
        font-size:16px;
        font-weight:bold;
        font-family:Arial, Helvetica, sans-serif;
        width:180px;
        padding-right:10px;
        margin-right:10px;
    #form .row .input {
        float:left;
        margin-right:10px;
        width:auto;
    /* width:auto;*/
    width: 455px;
    #form .row .input2 {
        float:left;
        margin-right:10px;
        width:auto;
    /* width:auto;*/
    width:455px;
    .detail {
        width:455px;
        font-family:Arial, Helvetica, sans-serif;
        font-size: 14px;
        padding: 10px 8px;
        margin:0px;
        display:block;
        border-radius:5px 5px 5px 5px;
        background:#e9e9e9;
        border:1px solid #ccc;
    .mess {
        width:455px;
        max-width:450px;
        height:280px;
        overflow:auto;
        font-family:Arial, Helvetica, sans-serif;
        font-size:14px;
        padding:7px 8px;
        line-height:1em;
        margin:0px;
        display:block;
        border-radius:5px 5px 5px 5px;
        background:#e9e9e9;
        border:1px solid #ccc;
    .detail:focus {
        background-color:#fff;
        border:1px solid #999;
        outline:none;
    .detail:mess {
        background-color:#fff;
        border:1px solid #999;
        outline:none;
    #form .row .context {
        color:#999;
        font-size:11px;
        font-style:italic;
        line-height:14px;
        font-family:Arial, Helvetica, sans-serif;
        width:200px;
        float:left;
    #form #submit {
        font-family:Arial, Helvetica, sans-serif;
        margin: 25px 0 0 0;
        color:#000;
        font-size:16px;
        text-shadow:1px 1px 1px #999;
        padding:10px;
    span.error{
        color:#000;  
        display:block;
        font-family:Arial, Helvetica, sans-serif;
        font-size:12px;
        background-image:url(http://www.bristolequestrianservices.co.uk/contact/images/x.png);
        background-repeat:no-repeat;
        background-position: 10px center;
        padding-left: 10%;
        width: 90%;
    #formWrap h2 {
        font-family:Arial, Helvetica, sans-serif;
        font-size: 26px;
        font-weight: normal;
        color:#255e67;
        margin: 25px 0 0 20px;
    </style>
    </head>
    <body>
    <div id="outer">
    <div id="wrapper">
    <div id="header">
    <div id="companyLogo">
    <img src="http://www.bristolequestrianservices.co.uk/images/logo4.jpg" alt="americanbarn" width="182" height="110" /><img src="http://www.bristolequestrianservices.co.uk/images/banner1.jpg" alt="horsebanner" width="302" height="84" />
    </div> <!-- end logo-->
    <div id="contact">
    <span class="phone">Tel: 07800538607 | 07920408396<br></span>
    <span class="email">Email: [email protected]</span>
    </div>
    </div>
    <!-- end header -->    
    <div id="topnav">
    <ul>
    <li><a href="index.html">Home</a></li>
    <li><a href="stables.html">Stables</a></li>
    <li><a href="shelters.html">Shelters</a></li>
    <li><a href="gallery.html">Gallery</a></li>
    <li><a href="pricelist.html">Price List</a></li>
    <li><a href="usefullinks.html">Useful Links</a></li>
    <li><a href="contactus.php">Contact Us</a></li>
    </ul>      
    </div>
    <img src="http://www.bristolequestrianservices.co.uk/images/photos/lisa1.jpg">
    <img src="http://www.bristolequestrianservices.co.uk/images/photos/me.jpg">       
    <div id="content">
    <h1>Contact Us</h1>
    <p><span class="big-blue">DUE TO A TECHNICAL ISSUE WITH THE CONTACT FORM PLEASE CONTACT US ON [email protected]</span><p>When contacting us please give us as much details as you can. If you want a quote for delivery please submit your post code. We will endeavour to respond to all emails within a few hours.</p>
    <p>Office opening hours: Monday to Friday 7.30am-6pm</p>
    <p>Saturday 8am-5pm</p>
    <p>Sunday CLOSED</p>
    <div id="formWrap">
    <h2>We Appreciate Your Feedback</h2>
    <div id="form">
    <?php if($form_complete === FALSE): ?>
    <form action="contact.php" method="post" id="comments_form">
    <div class="row">
    <div class="label">Your Name</div> <!--end .label -->
    <div class="input">
    <input type="text" id="fullname" class="detail" name="fullname" value="<?php echo isset($_POST['fullname'])? $_POST['fullname'] : ''; ?>" /><?php if(in_array('fullname', $validation)): ?><span class="error"><?php echo $error_messages['fullname']; ?></span><?php endif; ?>
    </div><!-- end .input -->
    </div><!-- end .row -->
    <div class="row">
    <div class="label">Your Email Address</div> <!--end .label -->
    <div class="input">
    <input type="text" id="email" class="detail" name="email" value="<?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>" /><?php if(in_array('email', $validation)): ?><span class="error"><?php echo $error_messages['email']; ?></span><?php endif; ?>
    </div><!-- end .input -->
    </div><!-- end .row -->
    <div class="row">
    <div class="label">Your Message</div> <!--end .label -->
    <div class="input2">
    <textarea id="comment" name="comment"  class="mess"><?php echo isset($_POST['comment'])? $_POST['comment'] : ''; ?>
    </textarea><?php if(in_array('comment', $validation)): ?><span class="error"><?php echo $error_messages['comment']; ?></span><?php endif; ?>
    </div><!-- end .input -->
    </div><!-- end .row -->
    <input type="submit" id="submit" name="submit" value="Send Message" />
    </form>
    <?php else: ?>
    <p style="font-size:35px; font-family:Arial, Helvetica, sans-serif; color:#255e67; margin-left:25px;">Thank you for your Message!</p>
    <script type="text/javascript">
    setTimeout('ourRedirect()', 5000)
    function ourRedirect () {
    location.href='index.html'
    </script>
    <?php endif; ?></div><!-- end #form-->
    </div><!-- end formWrap div -->
    </div>
    <div id="rightside">
    <h2>Latest News</h2>
    <p><a href="latestdesign.html">Our Latest Design</a></p>
    <p><a href="newpictures.html">New Pictures Added</a></p>
    <p><a href="testimonials.html">New Testimonials</a></p><br>
    <h4>View Gallery</h4><br>
    <img src="http://www.bristolequestrianservices.co.uk/images/buttons/viewgallery.jpg" /><br>
    <br><h4>Follow Us</h4><br>
    <div id="social-media-icons2">
    <ul>
    <li><a href="https://www.facebook.com/groups/150449201771804/"><img src="http://www.bristolequestrianservices.co.uk/images/icons/facebook.jpg" /></a></li>
    <li><a href="£"><img src="http://www.bristolequestrianservices.co.uk/images/icons/rss.jpg" /></a></li>
    <li><a href="http://www.twitter.com"><img src="http://www.bristolequestrianservices.co.uk/images/icons/twitter.jpg" /></a></li>
    <li><img src="http://www.bristolequestrianservices.co.uk/images/icons/youtube.jpg" /></li>
    </ul>
    </div>
    </div>
    <div id="rightside-bottom">
    <div id="footer">
    <p class="footer-text">Copyright 2014 Bristol Equestrian Services</p>
    </div>
    </div>
    </body>
    </html>

  • Can anyone help with my PHP contact form please!

    Hi all,
    I've just implemented the email contact form as described in the PHP Solutions book by David Powers and it is working fine.
    What I'm having problems with is my form is at the bottom of a long page and you have to scroll or click a link to get to it, which means that when the submit button is pressed, whether the form is successfully submitted or a field hasn't been completed, the user ends up back at the top of the page having to scroll back down to the form before they can see the feedback (either thanking them for submitting or pointing out that they have tried to submit an incomplete form).
    Can anyone tell me how I can make the page redirect upon clicking submit so that the user returns to the part of the page where the form is so they can see the feedback instead of going to the top of the page where the form is out of view.
    Many thanks,
    Karl.

    I've attached the entire code from the page plus the css so you can see what's going on and in additiion I've put in the corefuncs.php include code.
    Hope that's enough, thanks for looking.
    Cheers,
    Karl.
    <?php
    include('includes/corefuncs.php');
    if (function_exists('nukeMagicQuotes')) {
    nukeMagicQuotes();
    // process the email
    if (array_key_exists('send', $_POST)) {
    $to = '[email protected]'; // use your own email address
    $subject = 'Feedback from my form page';
    // list expected fields
    $expected = array('name', 'email', 'comments');
    // set required fields
    $required = array('name', 'email', 'comments');
    // create empty array for any missing fields
    $missing = array();
    // assume that there is nothing suspect
    $suspect = false;
    // create a pattern to locate suspect phrases
    $pattern = '/Content-Type:|Bcc:|Cc:/i';
    // function to check for suspect phrases
    function isSuspect($val, $pattern, &$suspect) {
         // if the variable is an array, loop through each element
         // and pass it recursively back to the same function
         if (is_array($val)) {
              foreach ($val as $item) {
                   isSuspect($item, $pattern, $suspect);
         else {
         // if one of the suspect phrases is found, set Boolean to true
              if (preg_match($pattern, $val)) {
                   $suspect = true;
    // check the $_POST array and any subarrays for suspect content
    isSuspect($_POST, $pattern, $suspect);
    if ($suspect) {
    $mailSent = false;
    unset($missing);
    else {
    // process the $_POST variables
    foreach ($_POST as $key => $value) {
    // assign to temporary variable and strip whitespace if not an array
    $temp = is_array($value) ? $value : trim($value);
    // if empty and required, add to $missing array
    if (empty($temp) && in_array($key, $required)) {
    array_push($missing, $key);
    // otherwise, assign to a variable of the same name as $key
    elseif (in_array($key, $expected)) {
    ${$key} = $temp;
    // validate the email address
    if (!empty($email)) {
    // regex to ensure no illegal characters in email address
    $checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
    // reject the email address if it doesn't match
    if (!preg_match($checkEmail, $email)) {
    array_push($missing, 'email');
    // go ahead only if not suspect and all required fields OK
    if (!$suspect && empty($missing)) {
    // build the message
    $message = "Name: $name\n\n";
    $message .= "Email: $email\n\n";
    $message .= "Comments: $comments";
    // limit line length to 70 characters
    $message = wordwrap($message, 70);
    // create additional headers
    $additionalHeaders = 'From: domain.com Feedback Form<[email protected]>';
    if (!empty($email)) {
    $additionalHeaders .= "\r\nReply-To: $email";
    // send it
    $mailSent = mail($to, $subject, $message, $additionalHeaders, '[email protected]');
    if ($mailSent) {
    // redirect the page with a fully qualified URL
    header('Location: http://www.domain.com/index.php#form-div');
    exit;
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Page | title</title>
    <script type="text/javascript" src="jquery.min.js">></script>
    <script type="text/javascript" src="jquery.cycle.all.2.72.js"></script>
    <script type="text/javascript">
    $(function() {
        $('#slideshow').cycle({
            speed:       1400,
            timeout:     8000
    </script>
    <link href="main.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <div id="wrapper" class="container">
    <div id="header">
    <h1 class="logo">XXX Xxxx Xxxxx</h1>
    <h2 class="subhead">Xxx Xxxxxxx xxx Xxxxxx Xxxxxxx xx Xxxx xxx Xxxxx.</h2>
    <div id="nav">
    <h2>Need more information?</h2>
    <h3>Look no further...</h3>
    <ul>
      <li><a class="nav-about" href="#about-div">About Us...</a></li>
      <li><a class="nav-contact" href="#contact-div">Contact Us...</a></li>
    </ul>
    </div>
    <!-- end nav -->
    </div><!-- end header -->
    <div id="page-content">
    <div id="cycle">
    <div id="cycle-nav"></div>
    <div id="slideshow" class="pics">
                <img src="im/slides/escape.jpg" border="0" alt="" title="" width="547" height="339" />
                <img src="im/slides/old-lady.jpg" border="0" alt="" title="" width="547" height="339" />
                <img src="im/slides/gouge.jpg" border="0" alt="" title="" width="547" height="339" />
                <img src="im/slides/disarm.jpg" border="0" alt="" title="" width="547" height="339" /></div><!-- slideshow -->
    </div><!-- cycle -->
    <div id="right-column">
    <div id="ladies">
    <h1>Xxxxxx xxx'x xxx xxxxx xxxx xxxx.</h1>
    <p>Xxxx xxxxxxxxx xxxx XXX xxxxx xxxxxxxxxx xxx xxxx xxxx xxxx xxxx!</p>
    <p class="bottom">XXXX XX xx xxxx xxx xxxx...</p>
    </div>
    <div id="courses">
         <div id="course1">
          <h2 class="top"><strong>Xxxx Xxxx Xxxxxxx Xxxxxx Xxxxxxx</strong></h2>
        <p>XXX Xxxx Xxxx Xxxxxxx xxxxxx xxx x xxxx-xxxx xxxxxxxx xxx xx xxxx xxxx xxxxx xxx xxxxxx.</p>
        <p><strong>XXXXX:</strong> XXX.XX xxx xxxxxx.</p>
        <p><strong>XXXX XXXXXX:</strong><br />
        Xxxxxx Xxx Xxxx<br /><strong>[XXXXXX XXXXXXXXX]</strong></p>
        <ul><strong>XXXXXX XXXXXXX:</strong>
    <li>Xxxxxx Xxx Xxxxxxxxx</li>
    <li>Xxxxxx Xxx Xxxxxxxx</li>
    <li>Xxxxxx Xx Xxxxxxx -XXXX</li>
    </ul>
        <h2>Xxxx Xxxxx...</h2>
        <p class="book-early">Xx xxxxx xxx xx xx xxxxxxxx xxxxxxx xxx xxx xxxxxxx xxx xxxxx xxxxxxxxxx xx x xxxxxxx xxxxxxx xxxxxxxx xx xxx xxxx xxx xxxxxxxxx xxxxxx xxxx xx xxxxx xx xxxxxxx xx xxx xxx xxxxxxxx xx xxxxxxxxx xx xxxxxx.</p>
        <h2><strong>Xxxxxxxxx xx xxx Xxxxxx</strong></h2>
        <p class="location">      XX. Xxxxxx Xxxx, <br />
          Xxx Xxxxxxxxx Xxxxxx, Xxxxxxxx Xxxx, Xxxx (xxxxx xxx xxxx xx xxxx).<br />
          Xxxxxxxx xx xxxxxxxxxxx xxxx xxxxxxxx Xxxx.</p>
        <h2><strong>Xxxxxxxxx xx xxx Xxxxxx</strong></h2>
        <p class="structure"><strong>Xxxxxxx xxxxxxx:</strong><br />
          XX.XXxx – XX.XX xx<br />
          <strong>Xxxxx xxxxx:</strong><br />
          XX xxxx.<br />
          Xxxxxx xxxxxxx xxxx xxx xxxxxx Xxxxx.<br />
          <strong>Xxxxxxxxxx xxxxxxx:</strong><br />XX.XXxx – X.XXxx</p>
        <h2><strong>Xxxxxx Xxxx...</strong></h2>
        <p class="news">Xxxxx xxxx xxxxx xxx xxxx xxxxx xxx Xxxx Xxxx Xxxxxxx Xxxxxx.<br />
        </p>
      </div>
      <div class="to-top">
      <p><a href="#header">[Back to Top]</a></p>
      </div>
         <div id="course2">
          <h2 class="top"><strong>Xxxxx Xxxx Xxxxxxx Xxxxx Xxxxxxx</strong></h2>
          <p>Xxx XXX XXXXX Xxxx Xxxxxxx Xxxxx xxx x xxx-xxxx xxxxxxxx xxx xx xxxx xxxxxx.</p>
        <p><strong>XXXXX:</strong> XX.XX xxx xxxxxx</p>
        <p><strong>XXXX XXXXX:</strong><br /> 
        Xxxxxx XXxx Xxx<br /><strong>[XXXXXX XXXXXXX]</strong></p>
        <ul><strong>XXXXXX XXXXXXX:</strong>
    <li>Xxxxxx Xxx Xxxx</li>
    <li>Xxxxxx Xxx Xxxx</li>
    <li>Xxxxxx Xxx Xxxx</li>
    <li>Xxxxxx Xxx Xxxx</li>
    </ul>
        <h2>Xxxx Xxxxx...</h2>
        <p class="book-early">Xx xxxxx xxx xx xx xxxxxxx xxxxxxx xxx xxx xxxxxxx xxx xxxxx xxxxxxxxxx xx x xxxxxxxxx xxxxxxx xxxxxxxx xx xxx xxxx xxx xxxxxxxxx xxxxxx xxxx xx xxxxx xx xxxxxxx xx xxx xxx xxxxxxxxxx xx xxxxxxxxx x xxxxxx.</p>
        <h2><strong>Xxxxxxxxx xx xxx Xxxxx</strong></h2>
        <p class="location">Xxxxxxxxx Xxxx, Xxxxxx Xxxxxx, Xxxxx, (xxx xxxxxxx xxxxxxxxx xx -<br />
          Xxxxxxx xx xxxxxxxxxx xxxx - </p>
        <h2><strong>Xxxxs Xxxx...</strong></h2>
        <p class="news">Xxxxx xxxx xxxxx xxx xxxx xxxxx xxx Xxxxx Xxxx Xxxxxxx Xxxxx.<br />
        </p>
      </div><!-- Course 2 end -->
      <div class="to-top">
      <p><a href="#header">[Back to Top]</a></p>
      </div>
    </div><!-- Courses end -->
    </div><!-- end right column -->
    <div id="main-content" >
    <div id="main-content-1" class="clearfix">
    <h2>Xxxxxxx xx xxx Xxxx Xxxxxxx<br />
    xxxxxxx xxxx xxx XXX.</h2>
    <h3>Xxxxxx xxx Xxxxx xxxxxxx…</h3>
    <p>Xxx XXX xx xx xxxxxxxxxxx xxxxx xxxxxx xxxxxxx xx xxxx xxxxxxx xx Xxxx xxx Xxxxx - Xxxx Xxxxxxxxx, xxxxxx xxxxxxxxx xx xxxxx xxxxxx xxx xxxxxx xxxxxx,   xxx xxxxxxxx x xxxx xxxxxxx xx xxxxxx xxxxxxxxx xx xxxxxxxx xxxx xxxxxxx.</p>
    <p>Xxx XXX xxxxxx xxx xxxxxxx xxx xxxxxxxx Xxxx Xxxxxxx xx xxx Xxxx / Xxxxx xxxx xx Xxxx Xxxxxxxxx.</p>
    <p>Xxx xxxxx xxxxxx xx x xxx xxx Xxxx Xxxxxxx Xxxxxx xxxx x xxxxxxxx xx xxxxxxxxx xxxx xxxxx xxxxx xx xxxx xx Xxxx xxxx xxxxx xxx xxxxxx xx xxx Xxxxxxxx Xxxxxx.</p>
    <p>Xxx xxxxxx xxxxxx xx x xxxxxx Xxxx Xxxxxxx Xxxxx xxxxx xx x xxx xxxx xxxxxxx xxx xx xxxx xx xxx xxxxxx xx xxxxx xx Xxxxxxxx Xxxx xx xxxxx Xxxxx Xxxxxx. Xxxxxxxx xxx xx xxxxx xx xxxx xxxxx.</p>
    <h3 class="extra-padding">Xxx xx xx xxx xxx xxxx xxxx xxx xxxxx?</h3>
    <p>Xxxx xxxxxx xx xxxxxxxxxx xxxxxx xx xxxxxx xxx xxx xxxx xxxxxx xxxxxxx xxx xxxx xxxxxx xx xx xxx xxxxxxxxxx xxx xxxx xx xxxx xx xx xxxxxxx xxxxxx xxxx xx xxxxxxxx xx xxxxxxxx xxxx xx xxxxxx xxxxxxxxxx xxxxxxx xxx xxxxxx xx xxxxx xxxxxxxx.</p>
    <p>xxx xxxx xx xxxxxx xxxx xx xxxxxx xxxxxxxxxx, xx x xxxxxxxx xxx xxxxxxx xxxxxxxxxxx xxxxx xxxxxx xxxxxxxxx xxx xxxx xxxx xx xxxxxxxxxxx xxxxxx xxxx xx xxxx.</p>
    <p>xxx xxxx xx xxxxxx xxxx xx xxxxxx xxxxxxxxxx, xx x xxxxxxxx xxx xxxxxxx xxxxxxxxxxx xxxxx xxxxxx xxxxxxxxx xxx xxxx xxxx xx xxxxxxxxxxx xxxxxx xxxx xx xxxx.</p>
    <p>xxx xxxx xx xxxxxx xxxx xx xxxxxx xxxxxxxxxx, xx x xxxxxxxx xxx xxxxxxx xxxxxxxxxxx xxxxx xxxxxx xxxxxxxxx xxx xxxx xxxx xx xxxxxxxxxxx xxxxxx xxxx xx xxxx.</p>
    <p><strong>xxx xxxx xx xxxxxx xxxx xx xxxxxx xxxxxxxxxx, xx x xxxxxxxx xxx xxxxxxx xxxxxxxxxxx xxxxx xxxxxx xxxxxxxxx xxx xxxx xxxx xx xxxxxxxxxxx xxxxxx xxxx xx xxxx.</strong></p>
    <p>xx xxxx xx xxxxxx xxxx xx xxxxxx xxxxxxxxxx, xx x xxxxxxxx xxx xxxxxxx xxxxxxxxxxx xxxxx xxxxxx xxxxxxxxx xxx xxxx xxxx xx xxxxxxxxxxx xxxxxx xxxx xx xxxx.</p>
    <p>xx xxxx xx xxxxxx xxxx xx xxxxxx xxxxxxxxxx, xx x xxxxxxxx xxx xxxxxxx xxxxxxxxxxx xxxxx xxxxxx xxxxxxxxx xxx xxxx xxxx xx xxxxxxxxxxx xxxxxx xxxx xx xxxx.</p>
    <p><strong>Xxxx xxxx xx xxxxxx xxxx xx xxxxxx xxxxxxxxxx, xx x xxxxxxxx xxx xxxxxxx xxxxxxxxxxx xxxxx xxxxxx xxxxxxxxx xxx xxxx xxxx xx xxxxxxxxxxx xxxxxx xxxx xx xxxx..</strong></p>
    <h3 class="extra-padding">Xxxxxxx xx…</h3>
    <h4>Xxx xxxxxxxxxx xx xxx Xxxx Xxxx Xxxxxxx Xxxxxx xxxxxxxx xxxx xxxxxx xxxx</h4>
    <h4>Xxx xxxxxxxxxx xx xxx Xxxx Xxxx Xxxxxxx Xxxxxx xxxxxxxx xxxx xxxxxx xxxx</h4>
    </div>
    <div id="main-content-2" class="clearfix">
      <h4> </h4>
    </div>
    </div><!-- end maincontent -->
    <div id="bottom-content">
    <div id="about-div">
    <h2>Xxxxx xx…</h2>
    <p>Xx, xx xxxxx ixx Xxxxxx Xxxxxxxxx xxxx xxxx xxxx xxxxxxx xxx xxxxxxxx xxxx xxxxxxx xxx xxxx xxxxxx xxxx xxxxx.</p>
    <p>Xx, xx xxxxx ixx Xxxxxx Xxxxxxxxx xxxx xxxx xxxx xxxxxxx xxx xxxxxxxx xxxx xxxxxxx xxx xxxx xxxxxx xxxx xxxxxXx, xx xxxxx ixx Xxxxxx Xxxxxxxxx xxxx xxxx xxxx xxxxxxx xxx xxxxxxxx xxxx xxxxxxx xxx xxxx xxxxxx xxxx xxxxx</p>
    <p>Xx, xx xxxxx ixx Xxxxxx Xxxxxxxxx xxxx xxxx xxxx xxxxxxx xxx xxxxxxxx xxxx xxxxxxx xxx xxxx xxxxxx xxxx xxxxx</p>
    <div class="about-bottom-to-top">
      <p><a href="#header">[Back to Top]</a></p>
      </div>
    </div>
    <hr />
    <div id="links-div">
    <h2>Xxxxxx xxxxx...</h2>
    <ul>
         <li><a href="">Xxx Xxxxx xxxx xxx xxx xxx xx(?)</a></li>
        <li><a href="">Xxx Xxxxx xxxx xxx xxx xxx xx(?)</a></li>
        <li><a href="">Xxx Xxxxx xxxx xxx xxx xxx xx(?)</a></li>
        <li><a href="">Xxx Xxxxx xxxx xxx xxx xxx xx(?)</a></li>
        <li><a href="">Xxx Xxxxx xxxx xxx xxx xxx xx(?)</a></li>
        <li><a href="">Xxx Xxxxx xxxx xxx xxx xxx xx(?)</a></li>
        <li><a href="">Xxx Xxxxx xxxx xxx xxx xxx xx(?)</a></li>
        <li><a href="">Xxx Xxxxx xxxx xxx xxx xxx xx(?)</a></li>
        <li><a href="">Xxx Xxxxx xxxx xxx xxx xxx xx(?)</a></li>
        <li><a href="">Xxx Xxxxx xxxx xxx xxx xxx xx(?)</a></li>
    </ul>
    </div>
    <div id="contact-div">
    <h2>Xxxxxx xxx...</h2>
    <p>Xxxxx x xxxx xxx xxx xxxxxxxxxx xxx xxxxxxx x xxxx xxx xxx xxxxxxxxxx xxx xxx xxxx x xxxx xxx xxx xxxxxxxxxx xxx xxxxxxx x xxxx xxx xxx xxxxxxxxxx xxx xxx<br />
    </p>
    <p class="phone">Xxxxx</p>
    </div>
    <div id="form-div">
         <p>Please make sure you complete all three fields below so that we can reply directly.</p>
         <?php
              if ($_POST && isset($missing) && !empty($missing))
              ?>
              <p class="warning">Please complete the missing item(s) indicated.</p>
              <?php
              elseif ($_POST && !$mailSent) {
              ?>
              <p class="warning">Sorry, there was a problem sending your message.
              Please try later.</p>
              <?php
              elseif ($_POST && $mailSent) {
              ?>
              <p class="thanks"><strong>Your message has been sent. Thank you for your feedback.
              </strong></p>
              <?php } ?>
      <form method="post" id="feedback" class="contactForm" action="">
                                              <label for="name">Name: <?php
                                                 if (isset($missing) && in_array('name', $missing)) { ?>
                                                 <span class="warning">Please enter your name</span><?php } ?>
                                              </label>
                                     <input name="name" id="name" type="text" class="formbox"
                                             <?php if (isset($missing)) {
                                                      echo 'value="'.htmlentities($_POST['name']).'"';
                                             } ?>
                                             />
                                              <label for="email">Email: <?php
                                                 if (isset($missing) && in_array('email', $missing)) { ?>
                                                 <span class="warning">Please enter a valid email address</span><?php } ?>
                                            </label>
                                        <input name="email" id="email" type="text" class="formbox"
                                            <?php if (isset($missing)) {
                                                      echo 'value="'.htmlentities($_POST['email']).'"';
                                            } ?>
                                            />
                                        <label for="comments">Comments: <?php
                                            if (isset($missing) && in_array('comments', $missing)) { ?>
                                            <span class="warning">Please enter your comments</span><?php } ?>
                                            </label>
                                        <textarea name="comments" id="comments" cols="30" rows="10"><?php
                                                 if (isset($missing)) {
                                                      echo htmlentities($_POST['comments']);
                                            } ?></textarea>
                                             <input name="send" id="send" class="formSubmit" type="submit" value="Send message" />
      </form>
       <div class="form-bottom-to-top">
      <p><a href="#header">[Back to Top]</a></p>
      </div>                         
    </div>
    </div>
    <div id="footer">
    <p>Xxxxxxxxxxxxx</p>
    </div>
    </div><!-- wrapper -->
    </div>
    <!-- end page-content -->
    </div><!-- end wrapper -->
    </body>
    </html>
    /* following is the include php code */
    <?php
    function nukeMagicQuotes() {
      if (get_magic_quotes_gpc()) {
        function stripslashes_deep($value) {
          $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
          return $value;
        $_POST = array_map('stripslashes_deep', $_POST);
        $_GET = array_map('stripslashes_deep', $_GET);
        $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
    ?>
    /* Following is the css */
    @charset "UTF-8";
    /* CSS Document */
    html { margin: 0; background: #faf9f2 url(im/background_texture_tile.jpg) top center repeat; text-align: center; }
    body { margin: 0 auto; background: url(im/background_texture_tile.jpg) top center repeat; text-align: center; width: 910px;
    padding: 0; font: 62.5% Arial, Verdana, Helvetica, sans-serif; }
    h1, h2, h3, h4, h5, h6, p, ul, ol, li, dl, dt, dd, form, label, fieldset, legend, blockquote, table { margin: 0; padding: 0; }
    #wrapper {
         text-align: left;     
         position: relative;
    .container{     
         margin: 0 auto 0;
         width: 910px;
    #header {
         width: 870px;
         height: 150px;
         margin: 0 20px 20px 20px ;
         background: url(im/header-bg.gif) top left no-repeat;
    h1.logo {
         float: left;
         height: 130px;
         width: 315px;     
         margin: 0 0 0 50px;
         border: 0;
         outline: 0;
         text-indent:-9999px;
         background:url(im/logo.jpg) 0 10px no-repeat;
         display: inline;
    h2.subhead {
         font-weight: bold;
         font-size: 1.6em;
         line-height: 1.4em;
         color: #999;
         float: right;
         width: 135px;
         text-align: right;
         margin: 25px 320px 0 0;
         display: inline;
    #nav {
         position: absolute;
         top: 0px;
         right: 50px;
         width: 270px;
         height: 277px;
         background: url(im/nav-bg.png) top left no-repeat;
    #nav h2 {
         font-size: 1.6em;
         text-align: center;
         color: #4D98C5;
         margin-top: 35px;
    #nav h3 {
         font-size:2.2em ;
         text-align: center;
         color: #4D98C5;
         padding-bottom: 13px;
         margin: 0 40px 0;
         border-bottom: 4.5px dotted #999;
    #nav ul {list-style:none;}
    #nav li {
    list-style:none;
    font-size: 1.4em;
    font-weight: bold;
    margin: 0 40px 0 40px ;
    border-bottom: 4.5px dotted #999;
    #nav li a {
    text-align: left;
    background-image:url(im/CSSSprite.jpg);
    background-repeat:no-repeat;
    color: #4D98C5;
    text-decoration: none;
    line-height: 65px;
    margin: 10px 0 10px 0;
    #nav li a.nav-about {
    background-position: 105px -15px;
    padding: 20px 95px 20px 0;
    #nav li a.nav-about:hover,
    #nav li a.nav-about:active,
    #nav li a.nav-about:focus {
    background-position: 105px -102px;
    color: #814098;
    #nav li a.nav-contact {
    background-position: 105px -180px;
    padding: 20px 80px 20px 0;
    #nav li a.nav-contact:hover,
    #nav li a.nav-contact:active,
    #nav li a.nav-contact:focus {
    background-position: 105px -267px;
    color: #814098;
    /* Cycle styles */
    #cycle {
         float: left;
         margin-left: 20px;
         margin-bottom: 25px;
         width: 547px;
         height: 339px;
         clear: both;
    .pics { height: 339px; width: 547px; padding:0; margin:0; overflow: hidden; border: 1px solid #814098; }
    /* End cycle styles */
    /*///// RIGHT CONTENT ////*/
    #right-column {
         float: right;
         width: 260px;
         margin: 0 53px 0 0;
         display: inline;
    #ladies {
         width: 252px;
         height: 437px;
         background: url(im/pink-ladies.png) top left no-repeat !important ;
         background: url(im/pink-ladies.gif) top left no-repeat ;
         margin: 120px 0 0 6px;
    #ladies h1 {
         margin: 0px 30px 150px 20px;
         padding-top: 60px;
         font: bold 2em Georgia, "Times New Roman", Times, serif;
         text-align: center;
         color: #6A437E;
    #ladies p {
         margin: 0px 30px 15px 20px;
         font: normal 1.8em Georgia, "Times New Roman", Times, serif;
         text-align: center;
         line-height: 1.4em;
         color: #EF4358;
    #ladies p.bottom {
         margin: 0px 30px 0px 20px;
         font: bold 2.2em Helvetica, Arial, sans-serif;
         text-align: center;
         color: #6A437E;
    #courses{
         margin-top: 15px;
         margin-bottom: 18px;
    #courses h2 {
         letter-spacing: .07em;
    /*Hull Course */
    #course1 {
         margin: 0 0 5px 6px ;
         width:240px;
         background:url(im/rightnav.gif) bottom left no-repeat;
    #course1 h2.top {
         background:url(im/rightnaw.gif) top left no-repeat;
         margin:0;
         padding:15px;
         color:#FFFFFF;
         font-size:1.6em;
         line-height: 1.4em;
         font-weight: bold;
         text-transform:uppercase;
    #course1 h2 {
         font-size:1.6em;
         line-height: 1.4em;
         color:#FFFFFF;
         background-color:#814198;
         padding:15px;
         text-transform:uppercase;
    #course1 p {
         font-size:1.4em;
         line-height:1.4em;
         padding: 15px 15px 0 15px;
         margin:0;
    #course1 p a {
         text-decoration:underline;
         font-weight:bold;
         color: #9f1f63     
    #course1 p a:hover {
         color: #ec008c;
    #course1 ul {
         margin: 20px 0 20px 15px;
         font-size:1.4em;
         line-height: 1.6em;
         list-style: none;
    #course1 p.book-early {
         padding-bottom: 20px;
    #course1 p.location {
         padding-bottom: 30px;
    #course1 p.structure {
         padding-bottom: 30px;
    #course1 p.news {
         padding-bottom: 30px;
    #right-column .to-top {
         color: #000;
         text-align: right;
         padding-right: 27px;
         margin-bottom: 40px;
    #right-column .to-top a, a:link {
         color: #000;
         font-size: 1.3em;     
         text-decoration: none;
    #right-column .to-top a:hover {
         text-decoration: underline;
    #course2 {
         margin: 0 0 5px 6px ;
         width:240px;
         background:url(im/rightnav.gif) bottom left no-repeat;
    #course2 h2.top {
         background:url(im/rightnaw.gif) top left no-repeat;
         margin:0;
         padding:15px;
         color:#FFFFFF;
         font-size:1.6em;
         line-height: 1.4em;
         font-weight: bold;
         text-transform:uppercase;
    #course2 h2 {
         font-size:1.6em;
         line-height: 1.4em;
         color:#FFFFFF;
         background-color:#814198;
         padding:15px;
         text-transform:uppercase;
    #course2 p {
         font-size:1.4em;
         line-height:1.4em;
         padding: 15px 15px 0 15px;
         margin:0;
    #course2 p a {
         text-decoration:underline;
         font-weight:bold;
         color: #9f1f63     
    #course2 p a:hover {
         color: #ec008c;
    #course2 ul {
         margin: 20px 0 20px 15px;
         font-size:1.4em;
         line-height: 1.6em;
         list-style: none;
    #course2 p.book-early {
         padding-bottom: 20px;
    #course2 p.location {
         padding-bottom: 30px;
    #course2 p.news {
         padding-bottom: 30px;
    /*///// RIGHT CONTENT ////*/
    #main-content {
         margin: 0 360px 0 40px;
         padding: 0;
    #main-content-1 {
         width: 510px;
    #main-content-2 {
         width: 510px;
    #main-content p {
         font-family: Arial, Verdana, Helvetica, sans-serif;
         font-size: 1.6em;
         line-height: 1.4em;
         padding-bottom: 1em;
         color: #666;
    #main-content h2{
         padding: 0 0 20px 0;
         margin: 0;
         font-family: Arial, Verdana, Helvetica, sans-serif;
         font-size: 3em;
         color: #666;
    #main-content h3 {
         font-size: 2.3em;
         color: #666;
         font-weight: normal;
         padding-bottom: 0.8em;
    #main-content h3.extra-padding {
         padding-top: 0.8em;
         padding-bottom: 0.8em;
    #main-content h4 {
         font-size: 2em;
         font-weight: normal;
    #bottom-content {     
         background-color: #814098;
         clear: both;
         margin: 0 20px;
         width: 870px;
         float: left;
    #bottom-content h2 {
         font-family: Arial, Verdana, Helvetica, sans-serif;
         font-size: 2.6em;
         letter-spacing: .05em;
         color: #FFF;
         font-style: normal;
         padding: 0 0 15px 0;
    #bottom-content p {
         color: #FFF;     
    #about-div {
         padding: 0 320px 30px 0;
         background: url(im/sheila.png) 560px 20px no-repeat !important;
         background: url(im/sheila.jpg) 560px 20px no-repeat ;
    #about-div h2 {
         padding: 20px 28px 15px 28px;
    #about-div p {
         padding: 0 28px 20px 28px;
         font-size: 1.5em;
         line-height: 1.4em;
    .about-bottom-to-top {
         position: relative;
         top: 65px;
         right: -320px;
         text-align: right;
         padding-right: 33px;
         font-size: .68em;     
    .about-bottom-to-top a, a:link {
         color: #FFF;
         text-decoration: none;
    .about-bottom-to-top a:hover {
         text-decoration: underline;
    hr {
           margin: 40px 28px 20px 28px;
           color: #C09FCB;
           border-top: 1px black solid;
    #links-div {
         margin: 0 15px 0px 28px;
         float: left;
         width: 254px;
    #links-div li {
         list-style: none;
         padding: 0 0;
    #links-div li a {
         font-size:1.5em;
         line-height: 1.5em;
         text-decoration: none;
         color: #FFF;
    #links-div li a:hover {
         text-decoration: underline;
    #contact-div {
         margin: 0 10px 0 0;
         width: 254px;
         float: left;
    #contact-div p {
         font-size: 1.5em;
         line-height: 1.4em;
    #contact-div p.phone {
         font-size: 2.2em;
         font-weight: bold;
         letter-spacing: .05em;
    /* CONTACT FORM */
    #form-div {
         margin: 0 28px 50px 0 ;
         float: right;
         width: 281px;
    #form-div .contactForm {
         padding:6px;
    #form-div .contactForm .formbox {
         font-family: Arial, Verdana, Helvetica, sans-serif;
         font-size:1.2em;
         color:#333;
         width:261px;
         padding:5px 3px;
         margin:0 0 5px 0 ;
         border:1px solid #666;
         border-top-color:#000;
         background:#fff url(im/contact-input.gif) top repeat-x;
    #form-div .contactForm #comments {
         font-family: Helvetica, Arial, sans-serif;
         font-size:1.23em;
         color:#333;
         line-height: 1.5em;
         width:258px;
         padding: 5px 0.4em 0 0.4em ;
         margin: 0 0 10px 0 ;
         display:block;
         clear:both;
         border:1px solid #666;
         border-top-color:#000;
         background:#fff url(im/contact-textarea.gif) top repeat-x;
    .formSubmit {
         display:block;
         clear:both;
         width:110px;     
         height:25px;
         padding:0;
         border:none;
         background-color: #251149;
         text-align:center;
         font-size:1.2em;
         color:#fff;
         cursor:pointer;
    .formSubmit:hover {
         background-color: #E76F34;
    .form-bottom-to-top {
         text-align: right;
         padding-right: 33px;
         font-size: 0.68em;     
         margin-top: 40px;
    .form-bottom-to-top a, a:link {
         color: #FFF;
         text-decoration: none;
    .form-bottom-to-top a:hover {
         text-decoration: underline;
    /* David Powers styles */
    .warning {
        font-weight: bold;
         font-size: 1em;
        color: #FCCCB9;
         display: block;
    .thanks {
        font-weight: bold;
        color: #f00;
         margin-left: 3px;
    #form-div p {
        margin: 0 0 10px 8px ;
         font-size: 1.5em;
         line-height: 1.4em;
    label {
        font-weight: bold;
         font-size: 1.6em;
        color: #FFF;
        display: block;
    /* END CONTACT FORM */
    #footer {
         height: 10em;
         background-color: #FFF;
         margin: 0 20px;
         clear: both;
    #footer p {
         font-size: 1.4em;
         color: #666;
         padding: 40px 0 30px 120px;     
         background: url(im/footer-logo.gif) 50px 20px no-repeat ;
    .clearfix:after{ content:"."; display:block; height:0; clear:both; visibility:hidden; }
    .clearfix {display: inline-block;}
    /* Hide from IE Mac \*/
    .clearfix {display:block;}
    /* End hide from IE Mac */
    * html .clearfix{ height: 1px; }

  • Problems using a php include file with an Add-on Domain.

    Hello,
    I am having an issue getting a php include file to work with a new add-on domain I am working on getting up and running.
    This include file is one that supplies the rest of the php code to a contact form page.  It works as it should for my original domain, same file no difference.  I made sure that the files hosted on the remote server had all read, write, execute permissions turned on.
    I have tried putting the include file in several different locations as a test, such as:
    I don't remember the exact name of the include file at the moment, as I'm at work so I will designate it below as 'includefile.php'.
    file path for add-on domain - ../public_html/lorentzpainting/includes/includefile.php
    alternatives I tried moving the file to - ../public_html/lorentzpainting/includefile.php
    When none of those options worked, I tried just pointing the path towards other places on the server that have the include file such as:
    ../public_html/includes/includefile.php
    ../public_html/includefile.php
    What can I do here?  Should I just give up on using the include and put all the code back in the page?  Doesn't seem like it should be this complicated, it works perfectly fine for my other site.. and still does.
    Thanks ahead of time to those who may assist me.

    here is the contents of the include file:
    <?php
    if (isset($_SERVER['SCRIPT_NAME']) && strpos($_SERVER['SCRIPT_NAME'],
    '.inc.php')) exit;
    // remove escape characters from POST array
    if (PHP_VERSION < 6 && get_magic_quotes_gpc()) {
      function stripslashes_deep($value) {
        $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
        return $value;
      $_POST = array_map('stripslashes_deep', $_POST);
      // assume that there is nothing suspect
        $suspect = false;
        // create a pattern to locate suspect phrases
        $pattern = '/Content-Type:|Bcc:|Cc:/i';
          // function to check for suspect phrases
      function isSuspect($val, $pattern, &$suspect) {
        // if the variable is an array, loop through each element
        // and pass it recursively back to the same function
        if (is_array($val)) {
          foreach ($val as $item) {
            isSuspect($item, $pattern, $suspect);
        else {
          // if one of the suspect phrases is found, set Boolean to true
          if (preg_match($pattern, $val)) {
            $suspect = true;
    //check the $_POST array and any subarrays for suspect content
    isSuspect($_POST, $pattern, $suspect);
        if (!empty($_POST['url'])) {
            $suspect = true;
        if ($suspect) {
            $mailSent = false;
            unset($missing);
        } else {
        //process the $_POST variables
        foreach ($_POST as $key => $value) {
            // assign to temporary variable and strip whitespace if not an array
            $temp = is_array($value) ? $value : trim($value);
            // if empty and required, add to $missing array
            if (empty($temp) && in_array($key, $required)) {
                array_push($missing, $key);
            } elseif (in_array($key, $expected)) {
                // otherwise, assign to a variable of the same name as $key
                ${$key} = $temp;
        //validate the email address
        if (!empty($email)) {
            // regex to identify illegal characters in email address
    $checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
    //reject the email address if it doesn't match
    if (!preg_match($checkEmail, $email)) {
        $suspect = true;
        $mailSent = false;
        unset($missing);
    //go ahead only if all required fields OK
        if (!$suspect && empty($missing)) {
    //initialize the $message variable
            $message = '';
    // loop through the $expected array
            foreach($expected as $item) {
    // assign the value of the current item to $val
                if (isset(${$item}) && !empty(${$item})) {
                    $val = ${$item};
                } else {
    // if it has no value, assign 'Not selected'
                    $val = 'Not selected';
    // if an array, expand as comma-sparated string
                if (is_array($val)) {
                    $val = implode(',', $val);
    // add label and value to the message body
      $message .= ucfirst($item).": $val\r\n\r\n";
    //limit line length to 70 characters
        $message = wordwrap($message, 70);
    //create Reply-To header
        if (!empty($email)) {
            $headers .= "\r\nReply-To: $email";
    // send it
        $mailSent = mail($to, $subject, $message, $headers);
        if ($mailSent) {
    // $missing is no longer needed if the email is sent, so unset it
            unset($missing); echo('Thank you for contacting Common Wealth Web Solutions');
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    </body>
    </html>

  • Php form processing script

    Hi. I got a program to write a php form processing script. My submit form is for photo submission to my domain email. I published to site and did a test to see if it works i got this error:
    Warning: require_once(F:\Domains\mydomain\mydomain.com\wwwroot/includes/Upload_Photos-lib.php): failed to open stream: No such file or directory in F:\Domains\mydomain\mydomain.com\wwwroot\Upload_Photos.php on line 24 Fatal error: require_once(): Failed opening required 'F:\Domains\mydomain\mydomain.com\wwwroot/includes/Upload_Photos-lib.php' (include_path='.;C:\php\pear') in F:\Domains\mydomain\mydomain.com\wwwroot\Upload_Photos.php on line 24
    What does this mean? How can i solve this so that i can process my form?

    See if the below form helps: You need to create a folder on your server named - upload - this is where any files uploaded will be stored (make sure the folder is writable. Also change the email address where the information that someone who has uploaded a file will go to. Look for the following in the code: $to ="XXXXXXXXXXXX.com";
    <!DOCTYPE html>
    <head>
    <meta charset="UTF-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    #wrapper {
    width: 400px;
    margin: 0 auto;
    </style>
    </head>
    <body>
    <div id="wrapper">
    <?php if(isset($_POST['submit'])) {
    $name = trim($_POST['name']);
    if(empty($name)) {
    $error['name'] = "Please provide your name";
    $location = trim($_POST['location']);
    if(empty($location)) {
    $error['location'] = "Please provide your location";
    $email = trim($_POST['email']);
    if(empty($email)) {
    $error['email'] = "Please provide your email";
    $category_description = trim($_POST['category_description']);
    if(empty($category_description)) {
    $error['category_description'] = "Please provide the category or description";
    $terms_conditions = trim($_POST['terms_conditions']);
    if(empty($terms_conditions)) {
    $error['terms_conditions'] = "Please accept the terms & conditions";
    $allowedExts = array(
       "doc",
      "docx",
            "rtf",
            "txt",
            "pdf",
            "jpeg",
            "jpg",
    $allowedMimeTypes = array(
      'application/msword',
            'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
            'application/rtf',
            'application/x-rtf',
            'text/richtext',
            'text/rtf',
            'application/plain',
      'application/pdf',
      'image/gif',
      'image/jpeg',
    $extension = end(explode(".", $_FILES["file"]["name"]));
    if (empty($_FILES["file"]["name"])) {
        $selectFile = 'Please select a file to upload';
    elseif ( ! ( in_array($extension, $allowedExts ) ) ) {
      $fileTypeNotAllowed = 'File type not allowed';
    elseif ($_FILES["file"]["size"] > 2097152) {
      $fileTooLarge = 'Please provide a smaller file';
    elseif (file_exists("upload/" . $_FILES["file"]["name"])) {
    $fileExists = $_FILES["file"]["name"] . " already exists, Please change the file name ";
    elseif (in_array( $_FILES["file"]["type"], $allowedMimeTypes ) )
        if(!empty($_POST['terms_conditions'])) {
    move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
        $fileName = $_FILES["file"]["name"];
        $fileUploadSuccessful = 'File uploaded successfully';
    $to = "XXXXXXXXXXXXX.com";
    $subject   = "Upload to website";
    $headers  = "From: $email\r\n";
    $headers .= "Reply-To: $email\r\n";
    $message = "Name: $name\n\n";
    $message .= "Location: $location\n\n";
    $message .= "Email Address: $email\n\n";
    $message .= "Category/Description: $category_description\n\n";
    $message .= "File: $fileName\n\n";
    mail($to, $subject, $message, $headers);
    $sent = "Mail was sent successfully";
    ?>
    <h1>Form</h1>
    <?php
    foreach ($error as $value) {
        echo "<p>".$value."</p>";
    if(isset($formFieldError)) {
    echo "<p>".$formFieldError."</p>";
    if(isset($selectFile)) {
    echo "<p>".$selectFile."</p>";
    if(isset($fileTypeNotAllowed)) {
    echo "<p>".$fileTypeNotAllowed."</p>";
    if(isset($fileTooLarge)) {
    echo "<p>".$fileTooLarge."</p>";
    if(isset($fileExists)) {
    echo "<p>".$fileExists."</p>";
    if(isset($fileUploadSuccessful)) {
    echo "<p>".$fileUploadSuccessful."</p>";
    ?>
    <form action="upload_file.php" method="post"
    enctype="multipart/form-data">
    <p>
    <label for="name">Name<br>
    <input type="text" name="name" id="name" value="<?php if(isset($name)) {echo $name; }  ?>"/>
    </label>
    </p>
    <p>
    <label for="location">Location<br>
    <input type="text" name="location" id="location" value="<?php if(isset($location)) {echo $location; }  ?>"/>
    </label>
    </p>
    <p>
    <label for="email">Email<br>
    <input type="text" name="email" id="email" value="<?php if(isset($email)) {echo $email; }  ?>" />
    </label>
    </p>
    <p>
    <label for="category_description">Category and Description<br>
    <input type="text" name="category_description" id="category_description" value="<?php if(isset($category_description)) {echo $category_description; }  ?>" />
    </label>
    </p>
    <p>
    <label for="file">File Attachment:<br>
    <input type="file" name="file" id="file" />
    </label>
    </p>
    <p>
    <label for="terms_conditions">Terms & Conditions:
    <input name="terms_conditions" type="checkbox" value="accept" <?php if(isset($_POST['terms_conditions'])) {echo "checked"; }  ?>> (Please check)
    </label>
    </p>
    <input type="submit" name="submit" value="Submit" />
    </form>
    </div>
    </body>
    </html>

  • Php form and mail handling

    I am trying to create a php form and I can get it to spit out the information from the form but I cannot seem to get it to send the result as an email.
    This is probably something really simple and I am totally missing it.
    Here is the form:
    <form method="post" action="sendail.php">               
      <?php
    $ipi = getenv("REMOTE_ADDR");
    $httprefi = getenv ("HTTP_REFERER");
    $httpagenti = getenv ("HTTP_USER_AGENT");
    ?>
      <input type="hidden" name="ip" value="<?php echo $ipi ?>" />
      <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
      <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
            <p>I need:<span class="redStar">*</span>
              <input type= "radio" name = "need" value = "service" />service.
            <input type= "radio" name = "need" value = "sales" />to contact a salesperson.
            <input type= "radio" name = "need" value = "literature" />to have literature sent to me.<br />
            Name:        <input type = "text" name = "name" size = "30" />
            <span class="redStar">*</span><br />
            Title:           <input type = "text" name = "title" size = "30" /><br />
            Company: <input type = "text" name = "company" size = "30" /></p>
            <p>Address 1: <input type = "text" name = "address1" size = "30" />
              <span class="redStar">*</span><br />
            Address 2: <input type = "text" name = "address2" size = "30" /><br />
            City: <input type = "text" name = "city" size = "30" />
            <span class="redStar">*</span> State: <input type = "text" name = "state" size = "3" />
            <span class="redStar">*</span> Zip: <input type = "text" name = "zip" size = "11" />
            <span class="redStar">*</span></p>
           <p>Email:   <input type = "text" name = "email" size = "30" />
             <span class="redStar">*</span><br />
            Phone: <input type = "text" name = "phone" size = "30" />
            <span class="redStar">*</span> </p>
            <p><input type = "submit" name = "submit" value = "Submit" /></p>
            <p><span class="redStar">*</span> These blanks must be filled in</p>
    </form>       
    and here is the page that handles the form (with the exception of the referring page, and other environmentals:
            <?php
            $ip = $_POST['ip'];
    $httpref = $_POST['httpref'];
    $httpagent = $_POST['httpagent'];
            $need = $_POST['need'];
            $name = $_POST['name'];
            $title = $_POST['title'];
            $company = $_POST['company'];
            $address1 = $_POST['address1'];
            $address2 = $_POST['address2'];
            $city = $_POST['city'];
            $state = $_POST['state'];
            $zip = $_POST['zip'];
            $email = $_POST['email'];
            $phone = $_POST['phone'];
    if(!$email == "" && (!strstr($email,"@") || !strstr($email,".")))
    echo "<h2>Use Back - Enter valid email</h2>\n";
    $badinput = "<h2>Your form was NOT submitted</h2>\n";
    echo $badinput;
    die ("Go back! ! ");
    if(empty($name) || empty($email) || empty($address1) || empty($city) || empty($state) || empty($zip) || empty($phone)) {
    echo "<h2>Use your Back button - fill in all starred fields, your form was not submitted.</h2>\n";
    die ("Use back! ! ");
    $todayis = date("l, F j, Y, g:i a") ;
    $subject = Contact_From_Website;
    $message = " $todayis [EST] \n
    From: $name ($email)\n
    Title: $title\n
    Company: $company\n
    Telephone: $phone ($phone)\n
    Address: $address1\n
    $address2\n
    City: $city\n
    State: $state\n
    Zip: $zip\n
    Phone: $phone\n
    Additional Info : IP = $ip \n
    Browser Info: $httpagent \n
    Referral : $httpref \n
    $from = "From: $email\r\n";
    mail("[email protected]", $name, $title, $company, $phone, $address1, $address2, $city, $state, $zip, $email, $phone, $ip, $httpref);
    /* This is the part that emails everyone and is commented out for testing
    if ($need = "service") {
        mail("[email protected]", $name, $title, $company, $phone, $address1, $address2, $city, $state, $zip, $email, $phone, $ip, $httpref);
    mail("[email protected]", $need, $name, $title, $company, $phone, $address1, $address2, $city, $state, $zip, $email, $phone, $ip, $httpref);
        if ($need = "sales") {
        mail("[email protected]", $need, $name, $title, $company, $phone, $address1, $address2, $city, $state, $zip, $email, $phone, $ip, $httpref);
            mail("[email protected]", $need, $name, $title, $company, $phone, $address1, $address2, $city, $state, $zip, $email, $phone, $ip, $httpref);
        if ($need = "literature") {
            mail("[email protected]", $need, $name, $title, $company, $phone, $address1, $address2, $city, $state, $zip, $email, $phone, $ip, $httpref);
    mail("[email protected]", $need, $name, $title, $company, $phone, $address1, $address2, $city, $state, $zip, $email, $phone, $ip, $httpref);
            ?>
            Date: <?php echo $todayis ?>
    <br />
    Thank You : <?php echo $name ?> ( <?php echo $email ?> )  <?php echo $title ?> <?php echo $company ?> <?php echo $phone ?> <?php echo $address1 ?> <?php echo $address2 ?> <?php echo $city ?> <?php echo $state ?> <?php echo $zip ?>
    <br /> You have requested <?php echo $need ?>
    <br /> Your IP Address has been recorded for your safety.
    <?php echo $ip ?>
    You can see where I am trying to go with this. I want to use the $need variable to determine where the email is going to go (two people in each case). But I am testing this script and cannot get to send me an email without any if statements.
    Where have I gone wrong?

    60251977 wrote:
    > I'm considering switching to Wordpress but have started
    building a site in
    > Dreamweaver, and am not especially keen on having to
    learn an entirely new
    > program.
    If you're not keen on learning, you might want to reconsider
    your plans.
    Creating a simple web page is easy, giving many beginners the
    false
    impression that website development is something anyone can
    do without
    acquiring specialist knowledge.
    > I want to create a simple "Add Comment" form so that
    when a visitor to my site
    > wants to comment, he can do so, press submit, and the
    page refreshes with his
    > comments inserted. Just like a blog.
    Yep, sounds simple enough, but so is turning the ignition key
    of a car.
    What you're ignoring is the underlying technology that not
    only makes it
    work, but makes it work safely. WordPress does all of this
    for you
    straight out of the box. To build it successfully in
    Dreamweaver
    requires a knowledge of PHP, MySQL, and SQL.
    > According to the Pickaweb FAQ, the path to PHP is
    "/usr/bin/php"
    If PHP is enabled on your site, the path to PHP is
    irrelevant.
    > If my site was called elephantlike.co.uk, what would I
    enter into the Action
    > field of the form wizard?
    > Would this make my form work? Or is there other stuff I
    need to know?
    What you enter in the Action field is the path to the script
    that
    processes the form input. If you're willing to learn the
    basics of PHP,
    MySQL, and SQL, you can create a comment form on your site
    with
    Dreamweaver. However, you need to be aware of security
    issues, such as
    cross-site scripting and dealing with spam. What looks simple
    at first
    glance is actually more complex. It's not rocket science, but
    it does
    involve a learning curve.
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS4",
    "PHP Solutions" & "PHP Object-Oriented Solutions"
    http://foundationphp.com/

  • PHP form strange behaviors

    I have a very basic PHP form coded and whenever I look at it in Live View the bottom third of the processing code appears at the top of the webpage. Uploaded the code does not appear on the webpage and the form works fine, except that the dropdown initial values I have set are ignored.
    The form URL:  http://affordableroofingcontractors.com/contact-us.php
    The dropdown code: (I want "select one" displayed but the form shows "Re-roofing" instead!?)
    <select name="service" id="service">
                <option value="0" selected="selected"
                <?php if (!$_POST ||$_POST['service'] =='0') {
        echo 'selected="selected"'; }?>>--select one--</option>
                <option value="Proactive Roof Maintenance"
                <?php if (!$_POST ||$_POST['service'] =='Proactive Roof Maintenance') {
        echo 'selected="selected"'; }?>>Proactive Roof Maintenance</option>
                <option value="Roof Repairs"
                 <?php if (!$_POST ||$_POST['service'] =='Roof Repairs') {
        echo 'selected="selected"'; }?>>Roof Repairs</option>
                <option value="Re-roofing"
                 <?php if (!$_POST ||$_POST['service'] =='Re-roofing') {
        echo 'selected="selected"'; }?>>Re-roofing</option>
              </select>
    The processing code:
    <?php
    if (array_key_exists('submit', $_POST)){
    //mail processing script
    // remove escape characters from POST array
    if (PHP_VERSION < 6 && get_magic_quotes_gpc()) {
      function stripslashes_deep($value) {
        $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
        return $value;
      $_POST = array_map('stripslashes_deep', $_POST);
    if (!empty($_POST['area'])) {
      $to = '[email protected]';
      $subject = 'SUSPECTED BOT SUBMISSION from ACI quote form';
    } else {
    $to = '[email protected]';
    $subject = 'ACI CONTACT FORM';
    //list expected fields
    $expected = array('name','company','phone','email','service','building','comments');
    //set required fields
    $required = array('name','email','phone');
    //create empty array for any missing fields
    $missing = array();
    //assume there is nothing suspect
    $suspect = false;
    //create a pattern to locate suspect phrases
    $pattern = '/Content-Type:|Bcc:|Cc:/i';
       // function to check for suspect phrases
      function isSuspect($val, $pattern, &$suspect) {
      // if the variable is an array, loop through each element and pass it recursively back to the same function
    if (is_array($val)) {
          foreach ($val as $item) {
         isSuspect($item, $pattern, $suspect);
        else {
          // if one of the suspect phrases is found, set Boolean to true
       if (preg_match($pattern, $val)) {
            $suspect = true;
    //check the Post array and any subarrays for suspect content
    isSuspect($_POST, $pattern, $suspect);
    if ($suspect) {
    $mailSent = false;
    unset($missing);
    } else {
    //process POST variables
    foreach ($_POST as $key => $value){
    //assign to temporary variable and strip whitespace if not an array
    $temp = is_array($value) ? $value : trim($value);
    //if empty and required, add to $missing array
    if (empty($temp) && in_array($key, $required)) {
      array_push($missing, $key);
    } elseif (in_array($key, $expected)) {
    //otherwise, assign to a variable of the same name as $key
      ${$key} = $temp;
    //validate the email address
    if (!empty($email)) {
    // regex to identify illegal characters in email address
    $checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
    //reject the email address if it doesn't match
    if (!preg_match($checkEmail, $email)){
      $suspect = true;
      $mailSent = false;
      unset($missing);
    //go ahead only if not suspect and all required fields OK
    if (!$suspect && empty($missing)) {
    //build the message
    $message = "Name: $name\r\n\r\n";
    $message .= "Company: $company\r\n\r\n";
    $message .= "Phone: $phone\r\n\r\n";
    $message .= "Email: $email\r\n\r\n";
    $message .= "Service Needed: $service\r\n\r\n";
    $message .= "Type of Building: $building\r\n\r\n";
    $message .= "Comments: $comments";
    //limit line length to 70 characters
    $message = wordwrap($message, 70);
    //create additional headers
    $headers = "From: $email>\r\n";
    $headers .= 'Content-Type: text/plain; charset=utf-8';
    if (!empty($email)) {
      $headers .= "\r\nReply-To: $email";
    //send it
    $mailSent = mail($to, $subject, $message, $headers);
    if ($mailSent) {
    //$missing is no longer needed if email is sent, so unset it
    unset($missing);
    ?>

    Hi!
    To select php form you should create a  menu,  fill out the type of "choice of one item of many" or "Select multiple  items from the many." Must be inside FORM element and have at the start  or end tags. It contains several elements OPTION, otherwise it makes no  sense.
    Example:
    <HTML> <body>
    <form method='post' action='all.php'>
         Color Scheme: <br>
        <SELECT NAME="color">
          <OPTION VALUE="Standard" SELECTED> </ OPTION>
          <OPTION VALUE='Brick'> Brick </ OPTION>
          <OPTION VALUE='Gray Mouse'> Gray Mouse </ OPTION>
          <OPTION VALUE='Ship Bottom'> Ship Bottom </ OPTION>
          <OPTION VALUE='Black Night'> Black Night </ OPTION>
          <OPTION VALUE='White Light'> White Light </ OPTION>
          <OPTION VALUE='Yellow List'> Yellow List </ OPTION>
          <OPTION VALUE='Pink Myth'> Pink Myth </ OPTION>
          <OPTION VALUE='Green USD'> Green USD </ OPTION>
          <OPTION VALUE='Standard'> Standard </ OPTION>
        </ SELECT>
    <input type='submit' name='submit' value='go'>
    </ form>
    </ body> </ HTML>2

Maybe you are looking for

  • Pls help!!

    I am still a learner, and i have to make a project. Using struts, I have to generate a HTML page on fly. This dynamic generation depends on the values I read from a XML file, which means I need to also do XML parsing. I have studied a little bit of D

  • Windows 7 (64 bit) iTunes 9.2 Outlook 2010 Sync Issues

    I've noticed bunch of conversations here about issues with the new version of iTunes NOT syncing with outlook contacts / calendars but none of them seem to be resolved. I also have lost my calendar sync since I installed the new iTunes. I have un-ins

  • "About my Mac" under "Storage" causing freezes

    Hello all, I usually figure these things out myself (relatively minor issues with my mac, OS X, etc.) but today I'm unable to resolve my issue. After installing an Intel 530 series 180gb MLC SSD, cloning my drive over, I've been having annoying long

  • How to validate whether a unpaid invoice is eligible for Cash discount or not ??

    Hi all, I need to display all the unpaid invoices which are eligible for cash discount only using a report. I'm getting bukrs, lifnr and posting date as selection criteria. BSIK as base table. Pls suggest me. thanks, Shameer.

  • Wanted: A Few Study Buddies

    Hello, I'd like to take the SCJP 1.4 on January 13th. I've worked my way through most of the Sybex Complete Java 2 Certification Guide (Programmer's Exam), and this morning I purchased the WhizLabs 1.4 mock exam simulator. See: http://www.whizlabs.co