Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To 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 September 14th, 2005, 01:24 AM
Registered User
 
Join Date: Sep 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default PHP contact form

i have a php form. i want some addtion form objects in this script. like jump menu and .. it takes values from jumop menu and send with mail.
<?php

// Add as many Names/ Departments -- e-mail addresses as you want here
$eMail[] = array( 'Information', 'princedevil@hotmail.com' );

// Handle older versions of PHP
if( ! isset( $_GET ) )$_GET = &$HTTP_GET_VARS;
if( ! isset( $_POST ) )$_POST = &$HTTP_POST_VARS;
if( ! isset( $_SERVER ) ) $_SERVER = &$HTTP_SERVER_VARS;

?>
<HTML>
<HEAD>
<TITLE>Mail Me!</TITLE>
</HEAD>
<BODY>

<?php if( ! isset( $_POST["EMail"] ) ) { ?>

<form method="POST" name="MailForm" <?php
  echo ((isset($_SERVER['PHP_SELF']))?'
  action="' . $_SERVER['PHP_SELF'] . '"' : '')?>>

  <div align="center">
    <center>
    <table border="0" cellpadding="4" cellspacing="0">
      <tr>
        <td valign="top" align="right">To:</td>
        <td><select size="1" name="To">
<?php
  foreach( $eMail as $k => $a )
    if( (isset($_GET["To"])) && ( $_GET["To"] == $k) )
        echo "<option value=\"$k\" selected>$a[0]</option>\n";
    else
        echo "<option value=\"$k\">$a[0]</option>\n";
?>
          </select>
           </td>
      </tr>
      <tr>
        <td valign="top" align="right">From:</td>
        <td><input type="text" name="From" size="44" maxlength="32"></td>
      </tr>
      <tr>
        <td valign="top" align="right">E-Mail:</td>
        <td><input type="text" name="EMail" size="44"></td>
      </tr>
      <tr>
        <td valign="top" align="right">Subject: </td>
        <td>
          <p align="center"><input type="text" name="Subject" size="44"></td>
      </tr>
    </table>
    </center>
  </div>
  <p align="center"><textarea rows="10" name="Body" cols="45"></textarea></p>
  <p align="center"><input type="submit" value="Send" name="B1"></p><br><br>
</form>

<?php
 } else {

   echo "<B> Attempting to send message </b></BR></BR>\n";

   $userip = ($_SERVER['X_FORWARDED_FOR']) ? $_SERVER['X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];

   if( get_magic_quotes_gpc() == 1 ) {
     $_POST["Subject"] = stripslashes( $_POST["Subject"] );
     $_POST["Body"] = stripslashes( $_POST["Body"] );
   }

   if( mail( '"' . $eMail[$_POST["To"]][0] . '" <' . $eMail[$_POST["To"]][1] . '>',
       $_POST["Subject"], $_POST["Body"],
       'Return-Path: "' . $_POST["From"] . '" <' . $_POST["EMail"] . ">\n"
       . 'From: "' . $_POST["From"] . '" <' . $_POST["EMail"] . ">\n"
       . 'Reply-To: "' . $_POST["From"] . '" <' . $_POST["EMail"] . ">\n"
       . "X-Mailer: PHP/" . phpversion() . "\n"
       . "X-From-IP: " . $userip ) )
     echo "Message Sent Successfully";
  else
      echo "UNABLE To Send Message.";
      print "please click " ;
print "<a href=\"./downloadAction.php?fileName=download.pdf\">";
print "here";
print "</a>";
print "to download. ";



}



?>
  </BODY>
</HTML>

Reply With Quote
  #2 (permalink)  
Old September 14th, 2005, 12:52 PM
Friend of Wrox
 
Join Date: Mar 2004
Location: Bhopal, MP, India.
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default


Hi,

You just need to add select as an PHP array variable. Get the post data and e-mail it.



`~@#\^%&*/\.<.\/-|+|_!:;..=?>
Support Indian students' finances http://scholarship.mediasworks.com/
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
Error With Contact Form ASP.NET 3.5 CSharpCoder BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 July 28th, 2008 04:08 PM
Contact Form and Gmail Jamessaep BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 5 April 16th, 2008 07:58 AM
Contact form XML attachments. retroviz BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 March 16th, 2008 09:52 AM
Contact Form myself Classic ASP Basics 1 November 18th, 2006 11:16 AM
Passing FORM to FORM to PHP AV1611 PHP Databases 1 August 17th, 2005 03:32 PM



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


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