...

View Full Version : Submit To Email



nathan130
10-27-2008, 05:20 AM
How do i make a form submit to an email?

rangana
10-27-2008, 06:35 AM
You can use PHP's mail (http://us.php.net/mail) function.

You might find these links useful:
http://email.about.com/cs/phpemailtips/qt/et031202.htm
http://www.sitepoint.com/article/advanced-email-php/
http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php

nathan130
10-28-2008, 12:28 AM
So How Do I Add This Code:


<?php
//define the receiver of the email
$to = 'Dwightshwrute@yahoo.com;
//define the subject of the email
$subject = 'Test Email';
//define the message to be sent. Each line should be separated with \n
$message = "Hello World!\n\nThis is my first mail.";
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: Dwightshwrute@yahoo.com\r\nReply-To: Dwightshwrute@yahoo,com";
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
?>

To This Code:


<html>
<body>

<form name="input" action="html_form_action.asp" method="get">
Male:
<input type="radio" name="Sex" value="Male" checked="checked">
<br>
Female:
<input type="radio" name="Sex" value="Female">
<br>
<input type ="submit" value ="Submit">
</form>

</body>
</html>

To Make It Work? Or Is Something Wrong In These Codes?

rangana
10-28-2008, 02:01 AM
You missed to close your string:


<?php
//define the receiver of the email
$to = 'Dwightshwrute@yahoo.com';
//define the subject of the email
$subject = 'Test Email';
.
.
.


I don't understand what you're doing. It seemed that your form's action is pointing to an ASP page, and what you have is a PHP script.

This works:


<?php
if(isset($_POST['submit']))
{
//define the receiver of the email
$to = 'Dwightshwrute@yahoo.com';
//define the subject of the email
$subject = 'Test Email';
//define the message to be sent. Each line should be separated with \n
$message = "Hello World!\n\nThis is my first mail.";
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: Dwightshwrute@yahoo.com\r\nReply-To: Dwightshwrute@yahoo,com";
//send the email
$mail_sent = mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
}
?>
<html>
<body>
<form name="input" action="<?php echo $_SERVER['php_self']; ?>" method="post">
Male:
<input type="radio" name="Sex" value="Male" checked="checked">
<br>
Female:
<input type="radio" name="Sex" value="Female">
<br>
<input type ="submit" value ="Submit" name="submit">
</form>
</body>
</html>

nathan130
10-29-2008, 02:31 AM
I want to make a form then when someone clicks submit it sends the info they entered to my email address.

I think that worked but i havent got the email yet so im not sure yet.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum