Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 3rd, 2007, 06:07 AM
Registered User
 
Join Date: May 2007
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 protected]"];
$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 protected]", "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.

 
Old May 11th, 2007, 06:23 PM
Registered User
 
Join Date: Jan 2005
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 protected]", "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
 
Old May 14th, 2007, 08:44 AM
Registered User
 
Join Date: May 2007
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.







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 [email protected] 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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.