Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 3rd, 2007, 06:07 AM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem using mail() from Ch11

Hi there, the is my first post here so please be gentle!!!

I've copied the code from ch11 in the Beginning php5, apache....book and can get the email to send.

Quote:
quote:<?php
$to = $_POST["email@website.com"];
$subject =$_POST["Contact Form"];
$name = $_POST["name"];
$address1 = $_POST["address1"];
$address2 = $_POST["address2"];
$address3 = $_POST["address3"];
$postcode = $_POST["postcode"];
$from = $_POST["from"];
$day = $_POST["day"];
$evening = $_POST["evening"];
$mobile = $_POST["mobile"];
$textArea = $_POST["textArea"];
$headers = "From: " . $name . "\r\n";
$mailsent = mail("email@website.com", "Contact Form", $textArea, $headers);
if ($mailsent) {
            echo "Congratulations ! The following message has been sent:<br><br>";
            echo "From: $name <br>";
            echo "Subject: $subject <br>";
            echo "Address: $address1 <br>";
            echo "$address2<br>";
            echo "$address3<br>";
            echo "$postcode<br>";
            echo "Day Telephone: $day<br> ";
            echo "Message sent was: ";
            echo $textArea;
            } else
            {
            echo "There was an error...";
            }
                        ?>

My problem is that when i check me email ONLY the $message is able to be read.

If i have a form with multiple input boxes ($name, $address, $telephone etc), how do i amend the code to display these in my email.

The form is a contact form and as such need all the information to be sent to me.

Many thanks for any help.

Reply With Quote
  #2 (permalink)  
Old May 11th, 2007, 06:23 PM
Registered User
 
Join Date: Jan 2005
Location: mabalacat, 1020, Philippines.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to cyber_kaley
Default



$name = $_POST["name"];
$address1 = $_POST["address1"];
$address2 = $_POST["address2"];
$address3 = $_POST["address3"];
$postcode = $_POST["postcode"];
$from = $_POST["from"];
$day = $_POST["day"];
$evening = $_POST["evening"];
$mobile = $_POST["mobile"];
$textArea = $_POST["textArea"];




$message = " --------------------------------------------------------<br>";
    $message .= " Name : ";
    $message .= " $name<br>";
    $message .= " address : ";
    $message .= " $address1<br>";
    $message .= " address2 : ";
    $message .= " $address2<br>";
    $message .= " Address3 : ";
    $message .= " $address3<br>";
    $message .= " postcode: ";
    $message .= " $postcode<br><br>";
        $message .= " Messages: ";
    $message .= " $textArea<br><br>";

    $message .= " --------------------------------------------------------<br>";





    $headers = "From: " . $name . "\r\n";
    $mailsent = mail("email@website.com", "Contact Form", $message, $headers);
    if ($mailsent) {
                echo "Congratulations ! The following message has been sent:<br><br>";
                echo "From: $name <br>";
                echo "Subject: $subject <br>";
                echo "Address: $address1 <br>";
                echo "$address2<br>";
                echo "$address3<br>";
                echo "$postcode<br>";
                echo "Day Telephone: $day<br> ";
                echo "Message sent was: ";
                echo $textArea;
                } else
                {
                echo "There was an error...";
                }
                            ?>






caley
Reply With Quote
  #3 (permalink)  
Old May 14th, 2007, 08:44 AM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply cyber_kaley.

Since i posted the message i realised how to edit the $message to include all the information.

Was a simple fix but thanks for the time taken to reply.


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ch11 msxml3 code prob humayunlalzad BOOK: Beginning XML 3rd Edition 1 May 19th, 2007 02:38 AM
ch11 "Using XML and Ajax" example doesn't work nick_rasband@byu.net BOOK: Beginning Ruby on Rails 2 March 27th, 2007 06:13 PM
Ch11 Exerc 3 Appendix A problem VictorVictor BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 February 16th, 2006 03:41 PM
code in CH11 not work in FireFox din BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 2 January 18th, 2006 09:21 PM



All times are GMT -4. The time now is 04:06 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.