📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

PHP Form?

2

Comments

  • vyseyboy
    vyseyboy Posts: 624 Forumite
    mikem1986 wrote: »
    hi vy!

    that worked, the text area bit came through on the email but nothing else did

    so how do i make it so all the info comes through?


    LOL. This PHP lark is easy. (Joke!)
    Russia is HERE
  • vyseyboy
    vyseyboy Posts: 624 Forumite
    mikem1986 wrote: »
    i think i got it working with

    <form method="post" action="contactbusiness.php">
    <p align="left">Your Name:
    <textarea name="message" rows="1" cols="15"></textarea>
    <br>
    Business Name:
    <textarea name="message" rows="1" cols="15"></textarea>
    <br>
    Category:
    <textarea name="message" rows="1" cols="15"></textarea>
    <br>
    Phone Number:
    <textarea name="message" rows="1" cols="15"></textarea>
    <br>
    Email:
    <textarea name="message" rows="1" cols="15"></textarea>
    <br>
    Website:
    <textarea name="message" rows="1" cols="15"></textarea>
    </p>


    <input type="submit">
    </p>
    </form>

    That won't do. Now you're creating lot's of "fields" called message, when in reality, each one should have a different name.

    e.g.
    Phone Number:
    <textarea name="phone_number" rows="1" cols="15"></textarea>
    <br>

    etc.


    What I meant before was keep the original HTML code, but just include the one extra line at the end, but before the submit button:

    <textarea name="message" rows="1" cols="15"></textarea>
    Russia is HERE
  • mikem1986
    mikem1986 Posts: 358 Forumite
    hi vy

    it didnt work after all

    for the php form i have

    <form method="post" action="contactbusiness.php"><?php
    $to = "[EMAIL="enquiries&#64;onethoughtpgd.co.uk"]enquiries@onethoughtpgd.co.uk[/EMAIL]";
    $subject = "Business Directory Listing";
    $email = $_REQUEST ;
    $message = $_REQUEST ;
    $busname = $_REQUEST;
    $cat = $_REQUEST;
    $phone = $_REQUEST;
    $web = $_REQUEST;
    $headers = "From: $email";
    $sent = mail($to, $subject, $email, $message, $business_name, $category, $phone_number, $website, $headers) ;
    if($sent)
    {print "Your mail was sent successfully, please allow 2-3 working days for your information to be placed on the site."; }
    else
    {print "We encountered an error sending your mail"; }
    ?>
    <br>
    </form>

    but im getting an error message saying
    Warning: mail() expects at most 5 parameters, 9 given in /home/sites/thisisglossop.co.uk/public_html/BusinessDirectory/contactbusiness.php on line 259
    We encountered an error sending your mail


    ive checked line 259 and everything seems fine?
    I need a cig...
  • vyseyboy
    vyseyboy Posts: 624 Forumite
    The line

    $sent = mail($to, $subject, $email, $message, $business_name, $category, $phone_number, $website, $headers) ;

    is the problem there. I'm not sure what it does exactly, but there's a maximum of 5 arguments and there's 9 of them there:

    The only arguments you need are outlined here: http://uk2.php.net/function.mail
    (see the examples at the bottom.)
    Russia is HERE
  • mikem1986
    mikem1986 Posts: 358 Forumite
    is there no way round cos i need all 9 forms really on the site?

    soooo annoying lol

    hope im not keeping you awake
    I need a cig...
  • vyseyboy
    vyseyboy Posts: 624 Forumite
    I'm really out of my depth here, but I think the mail() command only really needs the arguments:

    mail($to, $subject, $message, $headers);

    And probably not $headers. The way around it I can see would be to make the $message include the other bits of text from the html form (i.e $message is made up of $_REQUEST + $_REQUEST + $_REQUEST etc. so that all of those bits of information come through in the main body of the message to you. Sorry, I don't know how to do this.

    Probably best waiting for someone with more knowledge!
    Russia is HERE
  • mikem1986
    mikem1986 Posts: 358 Forumite
    thanks anyway vyseyboy

    youve been a good help!
    I need a cig...
  • vyseyboy
    vyseyboy Posts: 624 Forumite
    If you're willing to play around, you could try this, but I'm trying to learn how to do this on-the-fly myself :eek::

    <form method="post" action="contactbusiness.php"><?php
    $to = "[EMAIL="enquiries&#64;onethoughtpgd.co.uk"]enquiries@onethoughtpgd.co.uk[/EMAIL]";
    $subject = "Business Directory Listing";
    $email = $_REQUEST ;
    $message = "$_REQUEST /n $_REQUEST /n $_REQUEST /n $_REQUEST /n $_REQUEST" ;
    $headers = "From: $email";
    $sent = mail($to, $subject, $message, $headers) ;
    if($sent)
    {print "Your mail was sent successfully, please allow 2-3 working days for your information to be placed on the site."; }
    else
    {print "We encountered an error sending your mail"; }
    ?>
    <br>
    </form>
    Russia is HERE
  • M4RKM
    M4RKM Posts: 5,132 Forumite
    1,000 Posts Combo Breaker
    yeah... that is a big problem with the basic form in php... only supports a few fields...

    i'll root around later tonight and see if i can find a proper php form that gives you a bit of a better scope..

    never ever use spaces in anything you program btw...


    M
  • mikem1986
    mikem1986 Posts: 358 Forumite
    please delete asap
    I need a cig...
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 351.3K Banking & Borrowing
  • 253.2K Reduce Debt & Boost Income
  • 453.8K Spending & Discounts
  • 244.3K Work, Benefits & Business
  • 599.5K Mortgages, Homes & Bills
  • 177.1K Life & Family
  • 257.8K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16.2K Discuss & Feedback
  • 37.6K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.