You are invited to Log in or Register a free Frihost Account!

Contact Script

You know those e-mail forms on webpages, where you type your subject and message, a script sends your words via e-mail to somewhere?

I want one of those to put on my website. I have used mailto thingys, but they are obtrusive, and they won't work on setups without an e-mail client, or don't understand the mailto: protocol.

I realize that there are free services that provide e-mail forms, but to my knowledge, they require payment, or an ad (gasp!), and they have annoying setup processes that are supposed to "help" you in making a e-mail form.

I believe that those e-mail form scripts are simple. Correct me if I'm mistaken. If the script is really simple, I would appreciate it if someone walked me through making one, made me a script (out of the genourisity of his/her heart Smile ), or pointed me somewhere else on the internets. I know (X)HTML CSS really well (in my opinion), and some PHP. If the script is really complicated, post it here so that a Moderator could know and kindly move it into the Marketplace. Smile
really detailed, but highly rated...
Thanks, I'll check the article out.
are you still interest in a script after looking at that lovely 10-paged tutorial ? Very Happy
If not I can PM you a script that I use, want to try it out ?
Ah, 10 pages of technical hard-core coding instructions filled with non-sensical PHP scripts that have a sweet spot for giving out random errors? It's just some light reading.

Anyways, thanks for offering your script. The one I attempted just sends blank messages (eg: From: "" Message: ""). That was after I made it stop sending error messages. (I wasted 30 minutes just because I fogot that file names were case-sensitive...)

In short, yes, I would really appreciate your script so I can study it and modify it. That is, after I get rid of the infinite pile of blank messages in my inbox... Wink
The PHP mail() function is rather easy and should be more than sufficent.

Example code wrote:
$to      = '';
$subject = 'the subject';
$message = 'hello';
$headers = 'From:' . "\r\n" .
   'Reply-To:' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

you can of course change it so the inputs are gathered from a form, validated etc.

my short and sweet version Smile
if($_POST['submit']) {
   $email = "";    // Your Email - set your email here
   $yname = "me";    // Your name - set your name here
   $subject = "Feedback";          // Subject - set your subject here
   // Other inputs from form
   $from = $_POST['name'];
   $fromemail = $_POST['email'];
   $message = $_POST['comment'];
   // headers
   $headers .= 'To: '.$yname.' <'.$email.'>' . "\r\n";
   $headers .= 'From: '.$from.' <'.$fromemail.'>' . "\r\n";
   $headers .= 'Reply-To: '.$from.' <'.$fromemail.'>' . "\r\n"
   // try to send
   if (mail($email, $subject, $message, $headers)) {
      $formdetails = "Feedback succesfully sent!";
   } else {
      $formdetails = "Problem sending mail.";
   // display whether it send or not
   echo "<span style=\"color: #ff0000; font-weight: bold;\">".$formdetails."</span>";
<form name="feedback" action="" method="post">
Name: <input name="name" />
<br />Email: <input name="email" />
<br />Comment: <textarea name="comment" rows="2" columns="10"></textarea>
<br /><br /><button name="submit" type="submit">Send Feedback</button>

Pastebins down Sad
Some good features

* Email validation
* Field validation
* Sends IP
The varibles are coming out blank for me. I am using $_POST[''], but it turns out blank. I've uploaded the code to the frihost pastebin. The PHP file is here, and the HTML file is here. (Whoops, I used PHP syntax highlighting for HTML...)
It's your form. Use name instead of id.

for the length of the inputs you should be using size="" and for the textarea, cols="" and rows=""
NG theres a contact script there made by Leo Smile
Pluscontact 1.4 is coming out on that site soon.
Related topics
Web Mailer, Create a "contact us" mailer
Inserting data to MYSQL with a PHP script
CGI FormMail Script Part II
[php] travel agency script alike
Contact page without outlook
does anyone know the contact script and the comment pages
vraagje : contact script
Script execution problem
Need to change .pl style
For those who need a contact form
PHP script installation for $4 or FRIH$ 30 (Worth $1000)
PHP contact script...
contact form with IP feature ?
Submit Picture form script
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

© 2005-2011 Frihost, forums powered by phpBB.