Jump to content

eMail Form


Dysan

Recommended Posts

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

 

<form action="mailto:[email protected]?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
https://forums.phpfreaks.com/topic/88972-email-form/#findComment-455683
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
https://forums.phpfreaks.com/topic/88972-email-form/#findComment-455695
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('[email protected]','Contents of form',print_r($_POST,true),'From: [email protected]');
?>

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/88972-email-form/#findComment-455752
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.