📨 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?

I out a php form on my website today but when people are filling out the form im just getting blank emails and i dont know where its going wrong and wondered if you guys could help?

This is the form code
<form method="post" action="contactbusiness.php">
<p align="left">Your Name:
<input name="Name" type="text">
<br>
Business Name:
<input name="Business Name" type="text">
<br>
Category:
<input name="Category" type="text">
<br>
Phone Number:
<input name="Phone Number" type="text">
<br>
Email:
<input name="Email" type="text">
<br>
Website:
<input name="Website" type="text">
</p>

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

and the php code is
<form method="post" action="../BusinessDirectory/contactbusiness.php"><?php
$to = "[EMAIL="enquiries&#64;onethoughtpgd.co.uk"]enquiries@onethoughtpgd.co.uk[/EMAIL]";
$subject = "Business Directory Listing";
$email = $_REQUEST ;
$message = $_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>



can anyone please tel me where im going wrong?


Regards
I need a cig...
«13

Comments

  • mikem1986
    mikem1986 Posts: 358 Forumite
    can anyone help?
    I need a cig...
  • vyseyboy
    vyseyboy Posts: 624 Forumite
    I have never actually done any PHP before in my life, but looking over it, the PHP script references $_REQUEST , referring to a message that would be typed in on a text box, presumably, but the form HTML code doesn't have an "input" for the text variable 'message'.

    That's my complete amateur's analysis. Please take it with a pinch of salt.

    Edit: Have you had a look at your site? Does it actually have a text form for the "message"?

    You could try adding this between the <input name="Website" type="text"> and the </p> on the HTML form:

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

    Edit #2: I'd also get rid of the capital letters in the HTML code for fields such as Email, and make them all lowercase for consistency. It might not matter, it might.
    Russia is HERE
  • mikem1986
    mikem1986 Posts: 358 Forumite
    sounds worth giving a shot

    would i just put

    <input name="Name" type="text">

    somwhere in the form code?
    I need a cig...
  • M4RKM
    M4RKM Posts: 5,132 Forumite
    1,000 Posts Combo Breaker
    i do do php, badly...

    your form has no "message" so it can't send anything

    also, as you have more than 1 entry box, you need to rewrite it to make sure it sends the other fields..

    personally, when i use an email form i make sure i whack everything in a database, so even if my email is down, and it bounces, i still have everything... not as efficient, but very useful
  • mikem1986
    mikem1986 Posts: 358 Forumite
    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?
    I need a cig...
  • M4RKM
    M4RKM Posts: 5,132 Forumite
    1,000 Posts Combo Breaker
    ignore this post.... read below... more interesting
  • M4RKM
    M4RKM Posts: 5,132 Forumite
    1,000 Posts Combo Breaker
    try using this, and in your form, change things so they don't have a space in...

    i've started, but i'll let you finish

    <form method="post" action="../BusinessDirectory/contactbusiness.php"><?php
    $to = "enquiries&#64;onethoughtpgd.co.uk";
    $subject = "Business Directory Listing";
    $email = $_REQUEST['email'] ;
    $message = $_REQUEST['message'] ;
    $busname = $_REQUEST['business_name'];
    $cat = $_REQUEST['category'];
    $headers = "From: $email";
    $sent = mail($to, $subject, $message, $category, $business_name) ;
    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>
    


    i think.. its been a while since i did a form like this
  • mikem1986
    mikem1986 Posts: 358 Forumite
    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>
    I need a cig...
  • mikem1986
    mikem1986 Posts: 358 Forumite
    where youve put business_name

    does the underscore replace a space, do i have to put the underscore in?
    I need a cig...
  • PasturesNew
    PasturesNew Posts: 70,698 Forumite
    Part of the Furniture 10,000 Posts Name Dropper Photogenic
    Yes, put the underscore in. It's bad practice to use spaces in any names in any language or anything really with computers.

    Most/many languages won't recognise or accept a space.

    My pet hate is people that name Word documents with spaces in .... can really go haywire if they're used anywhere but on that person's PC.
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.7K 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.