http://www.pauserefreshment.co.uk/coffee-machine-brochure-request.html

Hi from wakefiled UK, v hot & humid...

Ive never done php before & today I tried but failed to get a form to ping back data filled out on a form to my eMail . The form in question is the top url link and screen grab of the form.

I know I have to create a seperate php file and whilst at the mo this is empty. I cleared all previous efforts as they failed miserably I do at least understand it needs a php script behind the form but I'm out of my depth big time:-(

heres the code for the 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 name="ROBOTS" CONTENT="NOINDEX,NOFOLLOW" />
<meta  name="Description" CONTENT="Request postal delivery of a coffee machine brochure for your office, hotel or pub" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Coffee machine brochure request form | pause... refreshment</title>
<link rel="stylesheet" type="text/css" href="css/brochure_form.css">
</head>
<body>
<form action="brochure.php" method="post">
  <h1>"Order a  brochure"</h1>
<fieldset>
    <div id="contact_details">
  <h2>Please enter your contact details</h2>
      <label for="name">First Name</label>
    <input type="text" name="name" id="name"/>
  </div>
  <div id="contact_details" >
    <label for="secondname">Second Name</label>
    <input type="text" name="secondname" id="secondname" />
  </div>
  <div id="contact_details">
    <label for="email">e Mail</label>
    <input type="text" name="email" id="email" />
  </div>
  <div id="contact_details">
    <label for="company">Company name</label>
    <input type="text" name="company" id="company"/>
  </div>
   <div id="contact_details">
    <label for="address">Address Line 1</label>
    <input type="text" name="address" id="address"/>
  </div>
  <div id="contact_details">
    <label for="address2">Address Line 2</label>
    <input type="text" name="address2" id="address2"/>
  </div>
  <div id="contact_details">
    <label for="postcode">Postcode</label>
    <input type="text" name="postcode" id="postcode"/>
  </div>
    <div id="brochure_pick">
    <h2>Select the brochure(s) you want posted</h2>
    <h3>Traditional & bean to cup<br/>
      "Ideal for restaurants and cafes"</h3>
    <label for="laspaziale">La Spaziale</label>
    <input type="checkbox" name="laspaziale" id="laspaziale"  />
    <label for="lacimbali">La Cimabli M1</label>
    <input type="checkbox" name="lacimbali" id="lacimbali"  />
     <label for="Koro">Koro</label>
    <input type="checkbox" name="koro" id="koro" />
    <label for="franke">Franke Flair</label>
    <input type="checkbox" name="franke" id="franke" />
    <h3>Instant<br/>
    "Ideal for offices"</h3>
  <div id="brochure_pick">
    <label for="vision400">Vision 400</label>
    <input type="checkbox" name="vision400" id="vision400" />
    <label for="darenth">Darenth</label>
    <input type="checkbox" name="darenth" id="darenth" />
  </div>
  <h3>Filter<br/>
    "Ideal for most set ups"</h3>
  <label for="mondo">Mondo</label>
  <input type="checkbox" name="mondo" id="mondo" />
  <label for="marco">Marco qwikbrew</label>
  <input type="checkbox" name="marco" id="marco" />
  </div>
    <div id="send">
    <input type="submit" value="Order Brochure">
  </div>
  </fieldset>
</form>
</body>
</html>

So my question is please...

"How do i begin to get a script to meake all entries ping back to me. Ive covered all sorts of tutorials but no luck :-(

Any insights welcome....

MOD EDIT: CODE bbcode tags changed to HTML tags.

    super simple example for brochure.php

    <?php
    $to = 'user@domain.com';
    $subject = 'the subject';
    $from = 'email@domain.com';
    $message ='';
    
    foreach($_POST as $name => $data)
    {
      if(is_array($data))
      {
        foreach($data as $datum)
        $message .= $name . ": " . $datum . " \n";
      }
    else
      $message .= $name . ": " . $data . " \n";
    }
    
    # Attempt to send email
    if(mail($to, $subject, $message, "From: $from"))
      echo "Mail sent";
    else
      echo "Mail send failure - message not sent";
    ?> 
    

      Dagon's code is pretty good standard code. However, mail can be a tricky thing sometimes due to spam filters, improper server configurations, etc. If the mail doesn't seem to get through, your PHP may be fine -- it could be somewhere else. You may find this thread informative.

      If you are still not receiving emails, you might consider having brochure.php write the form data to a file as well.

        Thank you for helping me out but alas i get this message:
        "Warning: mail() [function.mail]: SMTP server response: 554 <user@domain.com>: Recipient address rejected: Relay access denied in E:\domains\p\pauserefreshment.co.uk\user\htdocs\brochure.php on line 19
        Mail send failure - message not sent
        "

        If anyone has the time I would greatly appreciate any insight into why this form:
        http://www.pauserefreshment.co.uk/coffee-machine-brochure-request.html
        remains disabled :-(

          Check with your host (or whoever manages the SMTP server you're attempting to use); it sounds like SMTP authentication is required, in which case you'll have to use a 3rd party class (e.g. PHPMailer, XPertMailer, Pear:Mail, etc. etc.) as this is something PHP's internal mail() function can not do.

          EDIT: Also, first make sure that the "From" address is a valid e-mail address on your domain.

            Thanks Brad...

            Just reassure my self it wasn't a jinx with the code I did a tutorial the results of which can be seen here -
            http://www.pauserefreshment.co.uk/report.html
            I get the same problem. Ive pushed the problem onto our IT dept. Now at least thanks to your post I have an idea of where the problem may be coming from.

            If IT get back to me tomorrow I'll post the outcome here. I aint giving up 🙂

              bradgrafelman;10957623 wrote:

              Check with your host (or whoever manages the SMTP server you're attempting to use); it sounds like SMTP authentication is required, in which case you'll have to use a 3rd party class (e.g. PHPMailer, XPertMailer, Pear:Mail, etc. etc.) as this is something PHP's internal mail() function can not do.

              EDIT: Also, first make sure that the "From" address is a valid e-mail address on your domain.

              Just a quick question Brad...

              I note you advise the following - "Also, first make sure that the "From" address is a valid e-mail address on your domain"

              Does this mean if i was doing a form like this for another web site it has to have an eMail associated with it? What happens if the website like my photography site www.davidclick.com eMail address is david.honan@btinternet.com. Is the implication i'd have to get
              an eMail address like contact@davidclick.com for these types of scripts to work?

              Any insights welcome :-)

                The "From" address should be a valid e-mail address on your domain because doing otherwise basically means you're attempting to spoof the sender of the message. If you had a script on davidclick.com sending e-mails through a local SMTP server, then the e-mails aren't coming from david.honan@btinternet.com, so why would you want to use that address in the From header?

                  Pingbat;10957666 wrote:

                  I get the same problem. Ive pushed the problem onto our IT dept. Now at least thanks to your post I have an idea of where the problem may be coming from.

                  If IT get back to me tomorrow I'll post the outcome here. I aint giving up 🙂

                  I applaud your determination.

                  I would highly recommend using Pear::Mail. I had real problems connecting to google apps using PHPMailer. Pear::Mail had a better implementation and I was able to get secure emails moving. There's a nice piece of sample code here.

                  Ultimately, setting up a PHP script to send mail properly can be confusing because you deal with the same types of settings you fiddle with when setting up Outlook or Thunderbird (or Eudora). Different mail servers require different types of settings (such as user logins may require a full domain or not, unusual ports may need to be specified, etc.). Your hosting provider can take a look at the mail log when your mail fails and give you a better idea of what the problem is.

                    bradgrafelman;10957623 wrote:

                    Check with your host (or whoever manages the SMTP server you're attempting to use); it sounds like SMTP authentication is required, in which case you'll have to use a 3rd party class (e.g. PHPMailer, XPertMailer, Pear:Mail, etc. etc.) as this is something PHP's internal mail() function can not do.

                    EDIT: Also, first make sure that the "From" address is a valid e-mail address on your domain.

                    I Brad - I would like to say a big thank you :-)

                    This form is now fixed thanks to you spotting the SMTP authentification issue:
                    http://www.pauserefreshment.co.uk/report.html

                    Thanks again to your self and all the other phpbuilder members for helping me
                    get php fprms up and running :-)

                      Write a Reply...