Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Ovv
    Ovv is offline
    Junior Member
    Join Date
    Oct 2006
    Posts
    2
    Member #
    14228
    Hi,
    I have limited php knowledge and have used a tutorial to create the following for a friends website. When I submit the form the email arrives in my inbox however only the persons email and message appears. I also need their name and telephone number to show also. Each time I test it I only receive the email and message.
    What have a done wrong ?
    php code :
    PHP Code:
    <? 
    $name 
    $_REQUEST['name'] ; 
    $message $_REQUEST['message'] ; 
    $telno $_REQUEST['telno'] ; 
    $mailinglist $_REQUEST['mailinglist'] ; 
    $email $_REQUEST['email'] ; 

    mail"youremail@email.com""Website Enquiry Form"
    $message"From: $email); 
    header"Location: <A href="http://www.urllink/thankyou.html"" target=_blank>http://www.urllink/thankyou.html" ); 
    ?> 

    html in case thats wrong as well :
    <html>
    <head>
    <title>Contact Dolce Vita</title>
    <style>
    .form {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 70%;
    font-weight: normal;
    color: #4D4110;
    background-color:#f9c1da;
    padding: 3px
    }
    body {
     background-color: #ffffff;
    }
    </style>              
     
     
     <SCRIPT LANGUAGE="JAVASCRIPT">
                  <!-- hide JavaScript code from browsers that are not JavaScript enabled
     
     
                  function checkform()
                  { 
                  var message = "";  // create error message string variable, with nothing in it
                  // Test the First Name field has something in it 
                  if (document.contact.fullname.value =="") { 
                  message = message + "Please enter your full name\n"; 
                  }

       
                                     
                  // Test the phone number field has something in it
                  if (document.contact.telno.value =="") { 
                  message = message + "Please enter your phone number\n"; 
                  } 
                  // test for numeric digits only
                  else if (isNaN(document.contact.telno.value)) {                                            
                  message = message + "The phone number must only contain numbers\n"; 
                  }
                  //check email is valid
                  if (document.contact.email.value.indexOf("@") == -1 || document.contact.email.value.lastIndexOf(".") == -1) {
                  message = message + "Please enter a valid email address\n";
                    }
                  if (document.contact.email.value.lastIndexOf(".") < document.contact.email.value.indexOf("@")) {
                  message = message + "Please enter a valid email address\n";
                  }
                  if (document.contact.email.value.lastIndexOf(".") - document.contact.email.value.indexOf("@") == 1) {
                  message = message + "Please enter a valid email address\n";
                  }
     
     

     if ( message.length >0) { // is there an error message?
                                 alert( message ); // display error message
                                 return false; // return bad, not ok to process
                                 }
                                 else  {return true}
                                 } 
                
                 // end of the function checkform()
                //end hiding of JavaScript code -->
    </SCRIPT>       

    <meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
    <link href="html/css/styles.css" rel="stylesheet" type="text/css">
    </head>
    <body Onload="document.contact.firstname.focus()"> 
    <form method="post" action="sendmail.php">
    <table width="400" border=0 align="left" class="form">
    <tr>
    <td colspan="2">Please complete the following :</td>
    </tr>
    <tr>
    <td colspan="2">
    Name:<input name="name" type="text" >    
    <br></td>
    </tr>
    <tr>
    <td colspan="2">Your message:
      <p>
        <textarea name="message" cols="50" rows="10"></textarea>
      </td>
    </tr>
     
    </tr>
    <tr><td>Telephone Number:<input name="telno" type="text" ></td></tr>

    <td>
    Would you like us to contact you by phone?<br> <input type="radio" name="mailinglist" Value="Yes"> Yes <input type="radio" name="mailinglist" Value="No">No</td>
    <tr><td>
    Your email address: <input  name="email" type="text">
    </td>
    <tr>
     
     

    <tr><td><center>
    <input type="submit" name="Submit" value="Submit">
    <input type="reset" name="Reset" value="Reset">
    <br>
    </center></td></tr>
    </table>
    </form>
    </body>
    </html>
    Many Thanks in advance,
    Ovv

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Well, right now you aren't include the name in your email, which is why it's not showing up:
    PHP Code:
    mail"youremail@email.com""Website Enquiry Form"
        
    $message"From: $email); 
    Since your name isn't in there, your name can't possibly show up in the email. Something like this:
    PHP Code:
    mail"youremail@email.com""Website Enquiry Form"
    $message"From: $name <$email>" ); 
    The same goes for the rest of the info. If it's not in the actual call to mail, there's no way it's going to be mailed...

  4. #3
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,733
    Member #
    5580
    Liked
    718 times
    Give this a try. I think your problem is in the mail header ...
    This also re-directs to another page when finished sending.

    PHP Code:
    <?

    $recipient 
    "yourname@yoursite.com";
    $subject "Website Contact Form";
    $redirect "http://www.mysite.com";

    $sender $_REQUEST['email'];
    $username $_REQUEST['name'];
    $phone $_REQUEST['telno'];
    $fmessage $_REQUEST['message'];
    $mailinglist $_REQUEST['mailinglist'];

    $toaddr "$recipient";
    $subject "$subject";
    $senddate = (date("d M Y h:m:s -0500"));

    $message "

    $subject
    Online Form: 
    $senddate
    ---------------------------------------------------

    Name:  
    $username
      
    Phone: 
    $phone
    Email: 
    $sender
    Mailing List: 
    $mailinglist

    Message
    ---------------------------------------------------
    $fmessage

    ---------------------------------------------------
    "
    ;

    $extraheaders "From: $sender\nReply-To: $sender\n\n";

    if (! 
    mail($toaddr$subject$message$extraheaders))
      echo 
    "Mail did not send for some reason.";

    header("Location: ".$redirect);

    ?>


  5. #4
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    You might have to separate the headers by \r\n, as some servers only recognize that as a newline, and it's the only one specified as such in the SMTP RFC.

  6. #5
    Ovv
    Ovv is offline
    Junior Member
    Join Date
    Oct 2006
    Posts
    2
    Member #
    14228
    Mega fast replies !!
    Ok so I have two options. The code that mlseim has provided looks totally different -but I get the understand most of it.
    Otherwise, 2nd option is to make sure that where you have added $name, I also add $telno as well ??
    mail( "youremail@email.com", "Website Enquiry Form",
    $message, "From: $name $telno <$email>" );
    And if I have read correctly these need to be seperated, so adding in the \r\n inbetween these fields may be required ?
    Fantastic guys !


  7. #6
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,733
    Member #
    5580
    Liked
    718 times
    My method is actually the same when comes right down to the mail() part.
    It's just a little stretched out with creating $message ...

    I like my method a little better because it's easier to see what's happening,
    and easier to "build" the $message with whatever you want the email to look like.

    But, mail() is mail() ... same parameters.

    The question of \r\n is in this part: "From: $name \r\n $telno <$email>"

    My method looks like this:
    "From: $sender\nReply-To: $sender\n\n"

    and I've never had a problem with it.



Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:40 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com