|
|||||||
| PHP Discussion and technical support for using and deploying PHP based websites. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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: <input type="text" name="name" value="" size="20"><br /> Email: <input type="text" name="from" value="" size="20"><br /> Phone: <input type="text" name="Phone" value="" size="20"><br /> Address: <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> |
|
#2
|
||||
|
||||
|
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 |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
||||
|
||||
|
As you are "posting" the data back to the webserver you should be using the $_POST superglobal.
Eg. Code:
$name = $_POST['name']; |
|
#5
|
|||
|
|||
|
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! |
|
#6
|
||||
|
||||
|
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 |
|
#7
|
|||
|
|||
|
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'] ; |
|
#8
|
||||
|
||||
|
You have it set to "phone" (lowercase) whereas in your html you name it "Phone" (uppercase). Those are different.
Dave
__________________
Skinny Dog Studios |
|
#9
|
|||
|
|||
|
This doesn't work either. I think I need to get a book that spells it out more. Thanks anywaythough, appreciate it!
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|