PHP Woes!

Discussion in 'Web Design & Coding' started by Ownerer, Sep 23, 2010.

  1. Ownerer

    Ownerer

    Joined:
    Apr 30, 2006
    Messages:
    11
    Location:
    UK
    Hey guys. I can get a basic form (stolen from a template) to work, it is as follows:

    The HTML Form Code:

    <form method="post" action="sendmail.php">
    Client Email: <input name="email" type="text" /><br />
    Message:<br /> <textarea name="message" rows="15" cols="40"></textarea><br />
    <input type="submit" />
    </form>

    The sendmail.php code:

    <?php
    $email = $_REQUEST['email'] ;
    $message = $_REQUEST['message'] ;

    mail( "your@emailhere.com", "Feedback Form Results",
    $message, "From: $email" ) ;
    header( "Location: http://www.example.com/thankyou.html" );
    ?>

    ----------------------------------------------------------------------------------------------------------------------------

    The above, sends an email to my account which is 'from' the email address entered in the email input box. The details from the 'message' then are in the main body of the email. The page then redirects to the address specified.

    However whenever I try to add an input field, it doesn't work, and the same two things from before just come through. Oh, and obviously I update the HTML form code with a new input area as below in bold:

    <form method="post" action="sendmail.php">
    Client Email: <input name="email" type="text" /><br />
    Message:<br /> <textarea name="message" rows="15" cols="40"></textarea><br />
    Business Name: <input name="businessname" type="text" /><br />
    <input type="submit" />
    </form>

    If someone could tell me how to add additional fields and the necessary code in the PHP page, that would be greatly appreciated!

    I tried adding a field called 'businessname'

    then in the PHP file added the items in bold:

    <?php
    $email = $_REQUEST['email'] ;
    $message = $_REQUEST['message'] ;
    $businessename = $_REQUEST['businessemail'] ;

    mail( "your@emailhere.com", "Feedback Form Results",
    $message, "From: $email", $businessname, "Business Name: $businessname" ) ;
    header( "Location: http://www.example.com/thankyou.html" );
    ?>

    I'm totally unaware of how I should have entered the extra field information, so please tell me! The above was just an attempt I made!
     
    Ownerer, Sep 23, 2010
    #1
    1. Advertisements

  2. Ownerer

    S Walch MAME 0.64 :) VIP Member

    Joined:
    Jun 2, 2003
    Messages:
    1,026
    Location:
    Manchester
    I think the problem is this line: $businessename = $_REQUEST['businessemail'] ; - you have it trying to get a "businessemail" when actually all you have specified is a businessname.

    I don't know too much about PHP, and prefer to just use a CMS plus their relative plugins which do it a lot better than I could code myself.
     
    S Walch, Sep 24, 2010
    #2
    1. Advertisements

  3. Ownerer

    Ownerer

    Joined:
    Apr 30, 2006
    Messages:
    11
    Location:
    UK
    The businessname, businessemail thing was a mistake in how I typed the code in, in my example, sorry!

    A friend of mine gave me a hand and this code works perfectly:

    <?php
    $email = $_REQUEST['email'] ;
    $message = $_REQUEST['message'] ;
    $businessemail = $_REQUEST['businessemail'] ;

    mail("awpert@gmail.com", "Feedback Form Results",
    "Message: ".$message."\n"."Business name: ".$businessemail, "From: $email");
    header( "Location: http://www.google.co.uk" );
    ?>

    In case anyone has the same issue, that's how you add stuff! :)
     
    Ownerer, Sep 24, 2010
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SwordWielder

    PHP?

    SwordWielder, Mar 23, 2003, in forum: Web Design & Coding
    Replies:
    2
    Views:
    1,323
    SwordWielder
    Mar 24, 2003
  2. Josh

    Learn PHP in 24 hrs

    Josh, May 20, 2003, in forum: Web Design & Coding
    Replies:
    6
    Views:
    1,644
    lam3r
    Aug 16, 2003
  3. boxrick

    Making website in php, where to start?

    boxrick, Oct 14, 2003, in forum: Web Design & Coding
    Replies:
    1
    Views:
    1,397
    wordless
    Oct 22, 2003
  4. JMorris

    VbHome VS. PHP-Nuke

    JMorris, Dec 18, 2003, in forum: Software
    Replies:
    1
    Views:
    855
    JMorris
    Dec 18, 2003
  5. James
    Replies:
    2
    Views:
    1,309
    James
    Feb 14, 2004
  6. undeadpenguin

    MySQL/PHP Job/Tutorial

    undeadpenguin, Apr 7, 2004, in forum: Web Design & Coding
    Replies:
    1
    Views:
    1,144
    James
    Apr 12, 2004
  7. Ruler1

    What are some good PHP books?

    Ruler1, Jul 27, 2004, in forum: Web Design & Coding
    Replies:
    6
    Views:
    1,443
    Ruler1
    Jul 31, 2004
  8. ccraft

    Need A PHP Script

    ccraft, Sep 12, 2004, in forum: Web Design & Coding
    Replies:
    0
    Views:
    1,160
    ccraft
    Sep 12, 2004
Loading...