Jump to content

eMail Form


Dysan

Recommended Posts

here's a simple script that sends their comments and name

 

<form action="mailto:youremail@yourdomain.com?subject=form submission" method="post" enctype="text/plain">
<table><tr><td>

name: <INPUT NAME="name" TYPE="text" VALUE="name" SIZE=30><BR>

<br>


comments: <INPUT NAME="comments" TYPE="text" VALUE="comments" SIZE=50><BR>

<br> 

</td></tr>
<tr><td align=center>
<INPUT TYPE="submit" value="submit" style="color: #ffffff; background-color: #000000">
</td></tr></table>
</FORM>

 

Just edit it to what you want and change your e-mail  ask me if you need more help

 

and it uses the mailto: function

 

Link to comment
Share on other sites

Using PHP is pretty easy.

 

<?php

$get = $_GET['do'];

switch($get) {
  default:
    $form = '<form method="post" action="?do=sendmail">';
    $form .= 'Email To: <input type="text" name="sendto" /><br />';
    $form .= 'Your Email: <input type="text" name="email" /><br />';
    $form .= 'Subject: <input type="text" name="subject" /><br />';
    $form .= 'Message: <textarea name="message"></textarea><br />';
    $form .= '<input type="submit" value="Send" />';
    $form .= '<input type="hidden" name="form_check" value="1" />';
    $form .= '</form>';
    echo $form;
    break;

  case 'sendmail':
    if ( array_key_exists($_POST, 'form_check') ) {
      $sendto = $_POST['sendto'];
      $from= $_POST['email'];
      $subject = $_POST['subject'];
      $message = $_POST['message'];
      $message = nl2br($message); // Every new line is a break
      mail($sendto, $subject, $message, $from);
      echo 'Your mail has been successfully sent. Thank you for using our mail service.';
    } else {
      echo 'Your mail failed to be sent, Please go back and try again.';
    }
    break;
}
?>

This is a simple, and reasonably un-secure script, although not much damage could be done through an email.

 

Please bear in mind, i rarely test my code that i write on here. So please let me know if you encounter any issues.

Link to comment
Share on other sites

As I've posted many times, the easiest way is to just dump the contents of the $_POST or $_GET array to your email:

<?php
if (isset($_POST['submit'])) 
   mail('youremail@yourdomain.com','Contents of form',print_r($_POST,true),'From: youremail@yourdomain.com');
?>

 

Ken

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.