Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'checkbox array sent as email'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 1 result

  1. Hello, I have a file called Catform.php which allows users to 1) select products from 4 different product categories and 2) provide comments if they cannot find their product. This php file is linked to another file called handle_Catform.php which processes the user input and mail the input to my email address. Catform.php 1) On the Catform.php, to link to the handle_Catform.php, I used the following code: <form action="handle_Catform.php" method="post" ;> 2) For the 4 product categories, I arranged them using checkbox arrays. For example, for the SP category, I used the following code: <p style="font-weight:bold;" >S&P Equity Funds</p> <br> <input type="checkbox" name="SP[]" value="SP100" /> S&P 100 Fund <input type="checkbox" name="SP[]" value="SP200" /> S&P 200 Fund <input type="checkbox" name="SP[]" value="SP300" /> S&P 300 Fund Then for the other 3 categories (ND, DJ and RU), I just replaced the name from "SP[]" to "ND[]" and so forth. 3) For the user comment, I used textarea. I used the following code: <p style = "font-weight:bold;"> Comments</p> <textarea name="comments" rows="6" cols="60"></textarea> Handle_Catform.php I had no problem capturing and printing the user input from Catform.php. Below is an excerpt of my codes showing how I print input from the SP category and user input comments. <?php //this will receive the data from CatForm.php. //Create variables $username = $_POST['username']; $comments= $_POST['comments']; //Print Greetings print "Congratulations, $username! You have successfully made the following selections: <br> <br>"; //Print category SP if (isset($_POST['SP']) AND is_array($_POST['SP'])) { foreach ($_POST['SP'] as $SP) { print " $SP <br>\n "; } } else { print'No selection for SP<br>'; } //Print comments if (($_POST['comments'])!=""){ print " You provided the following comments: $comments <br>\n "; } else { print'You did not enter any comments. <br>'; } ?> Question: How do I use the mail () function to send the same user input to my email address on Handle_Catform.php? Please help! I tried the following codes but it did not work quite right and I don't know how to incorporate $comments in $body. I just need something like the following: For example, if the user selects only from SP category and provide comments " I want something else", then the email will look like: "From [the username of the user] We have received the following information: SP Selection = whatever user selected ND Selection = DJ Selection = RU Selection = Comments = I want something else." <?php //this will send the data from CatForm.php to my email address. //Create variables: $to = "my email address"; $username = $_POST['username']; $comments= $_POST['comments']; $from = $_POST['username'] $fields = array(); $fields{"SP"} = "SP Selection= "; $fields{"ND"} = "ND Selection= "; $fields{"DJ"} = "DJ Selection= "; $fields{"RU"} = "RU Selection= "; $subject = "Category Selections"; $headers = "From: $username"; $body = "We have received the following information:\n\n"; foreach($fields as $a => ${ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } mail($to, $subject, $message, $headers); } ?> Thank you so much. Jane
×
×
  • Create New...