Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
| 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 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 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>

 
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/




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





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