bator Posted August 4, 2007 Share Posted August 4, 2007 Hey guys, I'm trying to make a simple email script and I'm sure I'm overlooking something easy and I know one of you PHP Gurus can get this in a second. I have my HTML file with a form action for mailer.php the code for mailer.php is <?php $to = '[email protected]'; $subject = 'hello'; $message = 'this is the email message to php freaks.!'; $headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?> My question is, on the HTML file in the form, How can I get data from the website to be put into $to $subject, etc. I'm not sure how to link the two so that data i type in the text field will replace whats in the mailer.php script. I set the text field name to subject, etc but I'm just not knowledgeable enough to get it. thanks Link to comment https://forums.phpfreaks.com/topic/63262-php-newbie/ Share on other sites More sharing options...
php? Posted August 4, 2007 Share Posted August 4, 2007 Try putting this in the php help section Link to comment https://forums.phpfreaks.com/topic/63262-php-newbie/#findComment-315351 Share on other sites More sharing options...
nirvana4lf Posted August 5, 2007 Share Posted August 5, 2007 try deleting the headers variable. its not a required parameter in the mail(); function Link to comment https://forums.phpfreaks.com/topic/63262-php-newbie/#findComment-315827 Share on other sites More sharing options...
pyrodude Posted August 5, 2007 Share Posted August 5, 2007 Direct your form to that php file, then use $_POST['your_input_name_here'] to refer to each value. For example, you could set $to = $_POST['email_to']; $from = $_POST['email_from']; $subject = $_POST['subject']; and so on. Link to comment https://forums.phpfreaks.com/topic/63262-php-newbie/#findComment-316208 Share on other sites More sharing options...
tippy_102 Posted August 5, 2007 Share Posted August 5, 2007 I'll get you started.... The html file: <form name="email_form" method="post" action="send_email.php"> Email address: <input type="text" name="email_to" size="50"/> <!-- subject and message inputs go here --> <p><input type="submit" name="submit" id="submit" value="Submit;" /></p> </form> the php file called "send_email.php" <?php $email_to = mysql_real_escape_string($_POST['email_to']); if (empty($email_to)) { die('Email is empty. Please go <a href="javascript:history.back(-1);">back</a>.'); } // add above for subject and message $to = '[email protected]'; $subject = 'hello'; $message = 'this is the email message to php freaks.!'; $headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?> Link to comment https://forums.phpfreaks.com/topic/63262-php-newbie/#findComment-316294 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.