PDA

View Full Version : Simple php issue-Please help!



SEOGuru
17 Dec 2008, 11:40 AM
I have a couple contact forms on my site and I can't seem to get the mailform.php script correct.

I just need these forms to POST the content to my email:

Here's the html of both forms:

<form id='form' action='scripts/mailform2.php' enctype='multipart/form-data' name='form'>

<div align="left">
<p><img src="images/link_exchange.gif" alt="contact_us" class="indent_img"><span></span>
Please double-click to highlight the box below and add the following code to your site BEFORE contacting us. </p>
<textarea name="LinkHTML" rows=5 cols=46 wrap="hard">&lt;a href= &quot;http://www.ajspromotionalmedia.com/&quot;&gt;AJS Promotional Media - Search Engine Optimization (SEO) | Web Design&lt;/a&gt;
</textarea>
<p>We will verify that the link is not broken and contact you once your link is approved. </p>
<p> Site URL:<br>&nbsp;<br>
<input class="form" type="text" name="url">
<br>
&nbsp;<br>
E-mail address:<br>&nbsp;<br>
<input class="form" type="text" name="email"><br>&nbsp;<br>
Reciprocal Link Page:<br>&nbsp;<br>
<input class="form" type="text" name="backlink"><br>&nbsp;<br>
HTML as you wish it to be added in the directory. <br>
*anchor text (max. 35 characters):<br>&nbsp;<br>
<textarea rows="5" cols="5" class="textarea" name="anchorHTML"></textarea>
<a href="#" class="link_gray" onClick="document.getElementById('form').reset()">Clear</a><img src="images/spacer.gif" alt="spacer" width="8" height="1"><a href="#" class="link_gray" onClick="document.getElementById('form').submit()">Submit</a></div>
</form>

______________________________________________________________

<form id='form' action='scripts/mailform.php' enctype='multipart/form-data' name='form'>
<div>
<img src="images/6tx2.gif" alt="contact_us" class="indent_img">Contact us today and receive your copy of "101 Ways to Promote Your Website"<span></span>
Your name:
<input class="form" type="text" name="realname"><BR>
E-mail address:
<input class="form" type="text" name="email">
Your telephone:
<input class="form" type="text" name="phone">
Message:
<textarea rows="5" cols="5" class="textarea" name="message"></textarea>
<div><a href="#" class="link_gray" onClick="document.getElementById('form').reset()">Clear</a><img src="images/spacer.gif" alt="spacer" width="8" height="1"><a href="#" class="link_gray" onClick="document.getElementById('form2').submit()">Submit</a></div>

</div>
</form>

morestar
18 Dec 2008, 11:36 AM
Let me know if this works for you...


<form action="contact-me.php" method="post" enctype="multipart/form-data" name="frogprocess">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
</tr>
<tr>
<td id="main-text" width="27%" align="left">First Name:</a> </td>
<td width="65%" align="left"><input size="46" name="fname" type="text" /></td>
</tr>
<tr>
<td id="main-text" width="27%" align="left">Phone Number:</a> </td>
<td width="65%" align="left"><input size="46" name="phone" type="text" /></td>
</tr>
<tr>
<td id="main-text" width="27%" align="left">Email Address:</a> </td>
<td width="65%" align="left"><input size="46" name="email" type="text" /></td>
</tr>
<tr>
<td id="main-text" width="27%" align="left">Organization Name:</a> </td>
<td width="65%" align="left"><input size="46" name="organization" type="text" /></td>
</tr>
<tr>
<td id="main-text" width="27%" align="left">&nbsp;</td>
<td width="65%" align="left"><input name="submit" type="submit" /></td>
</tr>
</table>
</form>

This goes into a file, is should be the same name as the 'action' property in the <form> tag above...namely, contact-me.php



<?php

// the code block below gets the values/variables from your form
$fname = $_POST['fname'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$organization = $_POST['organization'];
// end getting values/variables from your form

// this is pretty much self explanatory
$subject = "Information from the website form";
$message = "
From: $fname: ($email)\n
First Name: $fname \n
Phone Number: $phone \n
Email Address: $email \n
Organization: $organization \n";


$from = $email;
$tomail = "me@mysite.com";

// the mail function below sends out the email
mail($tomail, $subject, $message, $from);

//the below code is your thank you page
header('Location: http://www.mysite.com/thank-you.html');

?>