www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > PHP

    PHP Discussion and technical support for using and deploying PHP based websites.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 10-05-2009, 07:19 PM
    jefito jefito is offline
    Registered User
     
    Join Date: Jul 2009
    Posts: 24
    new at php, trying to make a form work.

    Hi, I'm brand spanking new at php, and was trying to put together a contact form. It works just fine except the only info it sends is what is in the textarea "message" box". It dosen't send the name, phone, address, or anything. I've included the php which is a separate file on my site, and a sample of the html below which is on my contact page. Any help is highly appreciated. Thanks!

    THE PHP:


    <?php
    $name = $_REQUEST['name'] ;
    $email = $_REQUEST['email'] ;
    $phone = $_REQUEST['phone'] ;
    $address = $_REQUEST['address'] ;

    $message = $_REQUEST['message'] ;

    mail( "jeff.setnmefree@yahoo.com", "Feedback Form Results",
    $message, "From: $email" );
    header( "Location: http://www.set-n-me-free.com/thankyou.html" );
    ?>

    THE HTML:

    <div id="contact"><form method="post" action="sendmail.php">
    <p>Name: &nbsp; <input type="text" name="name" value="" size="20"><br />
    Email: &nbsp; <input type="text" name="from" value="" size="20"><br />
    Phone: &nbsp; <input type="text" name="Phone" value="" size="20"><br />
    Address: &nbsp; <input type="text" name="Address" value="" size="20"><br />


    <textarea name="message" rows="15" cols="40">
    </textarea><br /><br />
    <input type="submit" />

    </p>
    </form>
    </table>
    </div>
    Reply With Quote
      #2  
    Old 10-05-2009, 08:05 PM
    tracknut's Avatar
    tracknut tracknut is offline
    Registered User
     
    Join Date: Aug 2006
    Posts: 1,076
    The body of the mail message is that third parameter in the mail() function call. All you're putting in there is your variable $message, which you've filled with the value from your "message" text area. If you want the rest of the fields in there, you need to include them. Something like:

    $message = "New message from $name at tel no. $phone. He says $message";

    Dave
    __________________
    Skinny Dog Studios
    Reply With Quote
      #3  
    Old 10-06-2009, 03:08 AM
    littlened littlened is offline
    Registered User
     
    Join Date: Mar 2005
    Location: Costa Del Horden
    Posts: 65
    To debug what's being passed to your PHP script from the form try;

    <?php
    echo "<pre>";
    print_r($_REQUEST);
    echo "</pre>";
    ?>

    That will show you every variable coming from form.
    __________________
    Web design North East
    Reply With Quote
      #4  
    Old 10-06-2009, 08:36 AM
    thraddash's Avatar
    thraddash thraddash is offline
    Mega Man X
     
    Join Date: Aug 2009
    Location: South Africa, Midrand
    Posts: 258
    As you are "posting" the data back to the webserver you should be using the $_POST superglobal.

    Eg.

    Code:
    $name = $_POST['name'];
    Reply With Quote
      #5  
    Old 10-06-2009, 11:18 AM
    jefito jefito is offline
    Registered User
     
    Join Date: Jul 2009
    Posts: 24
    Thanks for the help, but I'm still confused. I tried this: $message = "New message from $name at tel no. $phone. He says $message";

    but this is what I got in my email: New message from jeff at tel no. . He says test

    I'm missing something here. Should I be doing separate entries like:

    $message = "New message from $name";
    $message = "New message from $phone"'

    I don't know how to write this up. Thanks!

    Thanks also for the tips on the 'echo' and the 'post' scripts!
    Reply With Quote
      #6  
    Old 10-06-2009, 11:24 AM
    tracknut's Avatar
    tracknut tracknut is offline
    Registered User
     
    Join Date: Aug 2006
    Posts: 1,076
    I just noticed your phone variable is actually named "Phone". So you need to change your request to:
    $phone = $_REQUEST['Phone'] ;

    Dave
    __________________
    Skinny Dog Studios
    Reply With Quote
      #7  
    Old 10-06-2009, 12:16 PM
    jefito jefito is offline
    Registered User
     
    Join Date: Jul 2009
    Posts: 24
    I already have it set to 'phone'. I always thought that these variables would be included as well as the message.

    <?php
    $name = $_REQUEST['name'] ;
    $email = $_REQUEST['email'] ;
    $phone = $_REQUEST['phone'] ;
    $address = $_REQUEST['address'] ;

    $message = $_REQUEST['message'] ;
    Reply With Quote
      #8  
    Old 10-06-2009, 12:59 PM
    tracknut's Avatar
    tracknut tracknut is offline
    Registered User
     
    Join Date: Aug 2006
    Posts: 1,076
    You have it set to "phone" (lowercase) whereas in your html you name it "Phone" (uppercase). Those are different.

    Dave
    __________________
    Skinny Dog Studios
    Reply With Quote
      #9  
    Old 10-06-2009, 01:10 PM
    jefito jefito is offline
    Registered User
     
    Join Date: Jul 2009
    Posts: 24
    This doesn't work either. I think I need to get a book that spells it out more. Thanks anywaythough, appreciate it!
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 02:40 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.