 400bandit World Chat Champion

Joined: 21 Dec 2005 Karma :  
|
 Posted: 16:05 - 05 Feb 2011 Post subject: HTML and PHP help needed |
 |
|
Hi All,
I have created a simple HTML form from which I want the information entered to send via email to me. I am no coder but can do bits and bobs. As I understand it I need a PHP script to send the information entered to an email address without the user having to manually send the email (i.e. using the standard HTML <form method="post"; action="mailto:[email protected]";>).
How much work does it take to get use PHP to send me the information entered into the form? I understand that there are many free PHP scripts out there that can be used for free but obviously need modifying. Can anyone recommend one?
Thanks,
Joe ____________________ Current Bikes 650 Honda Bros, VTR1000 Firestorm // Past Bikes: Sachs Madass 50/110cc - Bandit 400 - FZR750
(+ a XS650 in lots of pieces in my garage and other places...) |
|
 Frost World Chat Champion

Joined: 26 May 2004 Karma :  
|
 Posted: 16:50 - 05 Feb 2011 Post subject: |
 |
|
| Code: | <html>
<body>
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail( "[email protected]", "Subject: $subject",
$message, "From: $email" );
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?>
</body>
</html> |
Not tested and shamelessly nicked from w3 schools, but it'll work and do what you want. It's a good starting point to customise things yourself. |
|
 Ditto Nearly there...

Joined: 26 Sep 2009 Karma :  
|
 Posted: 23:32 - 06 Feb 2011 Post subject: |
 |
|
Yup, I used this one recently and it works well.
https://www.freecontactform.com/email_form.php
Basically add that HTML code into your website where you want the form to appear and Open notepad, paste the PHP code and save it as send_form_email.php.
Once online it will work. (Wont work offline!).
Change the email address in the PHP script to your own.
If you want the form to redirect back to your website, add this to the bottom of the PHP script. The red part is the bit to add, the rest is just the reference of where to add it.
------------------------------------------------------
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
header ("Location: thanks.html");
}
?> ____________________ CG 125 > Bandit 600 > CBR 600 FY > Street Triple R |
|
 TUG World Chat Champion
Joined: 12 May 2007 Karma :  
|
|