acidfire
12-12-2006, 12:44 PM
I'm trying to get a form to send me a users name and email for my newsletter. The problem I'm having is when I click the submit button it opens up my mail client instead of sending the info to my email. Can some one tell me what I'm doing wrong?
<form action="mailto:newsletter@my site.com?subject=Join Newsletter " method="post" enctype="text/plain">
<table><tr><td>
Name: <INPUT NAME="Name" TYPE="text" VALUE="Name" SIZE=20><BR>
Email: <INPUT NAME="Email" TYPE="text" VALUE="Email" SIZE=20><BR>
</td></tr>
<tr><td align=center>
<INPUT TYPE="submit" value="Submit" style="color: #ffffff; background-color: #000000">
</td></tr></table>
</FORM>
Thanks for any help you can give.
Odd Fact
12-12-2006, 01:38 PM
You ar going to need to use some form of form processor script. Take a look at hotscripts.
http://hotscripts.com/PHP/Scripts_and_Programs/Form_Processors/index.html
JediKnight2
12-12-2006, 02:33 PM
Yup...your form is doing exactly what you have told it to do...send it to the mailto address
David
12-13-2006, 05:35 PM
Jason,
Another option is to use the 'formmail' system available via your control panel. :)
If you require any assistance with it I'll be hiding on IRC! :)
L3-Carl
12-18-2006, 07:51 AM
Insert this code providing you can run PHP, at the top of your PHP page in PHP tags. You will need to run your own validation, this is a very simple contact form and works well
// Contact US Form PHP Code
// Carl Pickering - Line3 Internet Ltd
// Stops page from sending form when loaded
if($_POST['action']=='send') {
// define some variables first
$send_to = "uremail@domain.tld";
$subject = "Subject";
// Pop-Up Txt
$thank_you ="Thank you for enquiry, we will contact you back soon";
$c_person = $_POST['c_name'];
$c_email = $_POST['c_email'];
$c_phone = $_POST['c_phone'];
$c_message = $_POST['c_message'];
// Build the message
$message = "The following person has sent information from the website\n\n";
$message .= "Name: $c_person\n";
$message .= "Telephone: $c_phone\n";
$message .= "Email: $c_email\n";
$message .= "Message: $c_message \n";
$mailheaders = "From: $c_person <$c_email> \n";
$mailheaders .= "Reply-To: $c_person <$c_email>\n\n";
// Simple but basic.. Now send the email
mail($send_to, $subject, $message, $mailheaders);
print(" <script language=\"Javascript\"> alert('$thank_you'); </script> ");
}
Form Code:
<form action="contact.php" method="post" enctype="multipart/form-data" name="contact_us" id="form">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td height="23" style="padding:2px 0px 0px 0px;" align="right" width="100%">Your Name:</td>
<td><input name="c_name" type="text" class="input_2" id="c_name"></td>
</tr>
<tr>
<td height="23" style="padding:2px 0px 0px 0px;" align="right" width="100%">Your Phone:</td>
<td><input name="c_phone" type="text" class="input_2" id="c_phone"></td>
</tr>
<tr>
<td height="23" style="padding:2px 0px 0px 0px;" align="right">Your email: </td>
<td><input name="c_email" type="text" class="input_2" id="c_email"></td>
</tr>
<tr>
<td height="23" style="padding:2px 0px 0px 0px;" align="right" width="100%">Message:</td>
<td><textarea name="c_message" cols="3" rows="3" id="c_message"></textarea></td>
</tr>
<tr>
<td width="100%"><img src="images/spacer.gif" width="1" height="1" alt=""><input name="action" type="hidden" id="action" value="send"></td>
<td align="right" style="padding:5px 0px 0px 0px;"><img src="images/read_1.gif" alt="" style="margin:0px 5px 0px 0px;"><a href="javascript:document.contact_us.reset();">Reset</a><img src="images/read_1.gif" alt="" style="margin:0px 5px 0px 30px;"><a href="javascript:document.contact_us.submit();">Submit</a></td>
</tr>
</table>
</form>
Notice the hidden form element, the form will only be posted, if that variable is sent.
You may wanna use strip_tags on your code too, before posting, stops people injecting nasty code.... I do :)
HTH - Like i said, its dead basic, but gets you going
acidfire
01-05-2007, 12:15 PM
Thanks for the reply's. Sorry for the late reply but I was busy with the holidays. Thanks for the info David and I will look into that. And thanks for the code cpickering.
It looks a great code.
Is it possible to integrate validation code in the form?
I'm looking for that long time.
Thank you,