Forums

PHP

This topic is locked

submit form using php

Posted 09 Oct 2006 19:43:46
1
has voted
09 Oct 2006 19:43:46 tom baker posted:
so I have this form:
<pre id=code><font face=courier size=2 id=code> &lt;form action="websiteurl/meadowform.php" method="post" id="form" style="margin:0; padding:0 "&gt;
&lt;table cellpadding="0" cellspacing="0" border="0"
&lt;tr&gt;
&lt;td valign="top" width="206" eight="232"&gt;
&lt;div style="margin:19 0 0 22px "&gt;&lt;img src="www.webmasterforums.com/images/5_w2.gif" alt="" border="0" style="margin-left:-9px; margin-bottom:21px "&gt;&lt;br&gt;
&lt;input type="text" style=" width:182px; height:27px" value=" &nbsp;name:"&gt;&lt;br&gt;&lt;br style="line-height:1px "&gt;&lt;input type="text" style=" width:182px; height:27px" value=" &nbsp;e-mail:"&gt;&lt;br&gt;&lt;br style="line-height:1px "&gt;&lt;input type="text" style=" width:182px; height:27px" value=" &nbsp;phone:"&gt;&lt;br&gt;&lt;br style="line-height:1px "&gt;&lt;input type="text" style=" width:182px; height:27px" value=" &nbsp;preference (email or phone):"&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td valign="top" width="320" height="232"&gt;
&lt;div style=" margin:49 0 0 0px"&gt;&lt;textarea cols="35" rows="35" style=" width:272px; height:117px; overflow:hidden " &gt; &nbsp;How we can help you:&lt;/textarea&gt;&lt;br&gt;&lt;br style="line-height:7px "&gt;
&lt;img alt="" src="www.webmasterforums.com/images/spacer.gif" width="150px" height="1px"&gt;&lt;a href="#" onclick="document.getElementById('form').reset()"&gt;&lt;font color="#330000"&gt;RESET&lt;/font&gt;&lt;/a&gt;&lt;img alt="" src="www.webmasterforums.com/images/spacer.gif" width="28px" height="1px"&gt;&lt;a href="index-ty.htm" onclick="document.getElementById('form').submit()"&gt;&lt;font color="#330000"&gt;SUBMIT&lt;/font&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;</font id=code></pre id=code>

and I've go this script named meadowform:

<pre id=code><font face=courier size=2 id=code>&lt;?php
if(isset($_POST['submit'])){
$message = null;
foreach($_POST as $k =&gt; $v){
if($k!='submit')
$message .= "$k: $v\n\n";
}
}
mail(' ', 'someone has contacted you from companyname.com', $message);
?&gt; </font id=code></pre id=code>

Now I want to have the script email me (as it does now) when someone hits the submit button, however I would like to include the text fields above (name, email, phone, preference, and comments) in the email that gets sent to me.

<b>Anyone able to help me with what needs to be included in the PHP script to capture the form data and include it in an email to mysef without posting to a DB?</b>

Replies

Replied 17 Oct 2006 07:17:51
17 Oct 2006 07:17:51 micah santos replied:
try this one:

&lt;?php

// setting variables

$name = $_POST['sender_name'];
$subject = $_POST['sender_subject'];
$email = $_POST['sender_email'];
$message = $_POST['sender_message'];


// sending message to the recipient

$to = " ";
$subject = $_POST['sender_subject'];
$msg = $message . $_POST['sender_name'] . $getip;
$headers = "From: " . $_POST['sender_email'] . "\r\nReply-To:" . $_POST['sender_email'];


mail("$to", "$subject", "$msg", "$headers";

?&gt;

Reply to this topic