Jump to content

[SOLVED] mail script


speciesbeing

Recommended Posts

Hi! :)

 

I am new to this forum and on the start I have little problem.

 

I have small mail script, but I need to put inside it time and date.

 

<script language="php">
$email = $HTTP_POST_VARS[email];
$mailto = "email@address";
$mailsubj = "Form submission";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from web site form:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $val\n"; }
if (!eregi("\n",$HTTP_POST_VARS[email])) { mail($mailto, $mailsubj, $mailbody, $mailhead); }
</script>

 

How will I do this?

Link to comment
https://forums.phpfreaks.com/topic/112666-solved-mail-script/
Share on other sites

Hello.

 

http://us2.php.net/date

 

<?php
// Assuming today is: March 10th, 2001, 5:16:18 pm

$today = date("F j, Y, g:i a");                 // March 10, 2001, 5:16 pm
$today = date("m.d.y");                         // 03.10.01
$today = date("j, n, Y");                       // 10, 3, 2001
$today = date("Ymd");                           // 20010310
$today = date('h-i-s, j-m-y, it is w Day z ');  // 05-16-17, 10-03-01, 1631 1618 6 Fripm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.');   // It is the 10th day.
$today = date("D M j G:i:s T Y");               // Sat Mar 10 15:16:08 MST 2001
$today = date('H:m:s \m \i\s\ \m\o\n\t\h');     // 17:03:17 m is month
$today = date("H:i:s");                         // 17:16:17
?>

Link to comment
https://forums.phpfreaks.com/topic/112666-solved-mail-script/#findComment-578650
Share on other sites

<?php


$email = addslashes(strip_tags($HTTP_POST_VARS[email]));
$mailto = "email@address";
$mailsubj = "Form submission";
$mailhead = "From: $email\r\n";
reset ($HTTP_POST_VARS);
$mailbody = "Date: ".date("l jS \of F Y h:i:s A")."\r\nValues submitted from web site form:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $val\n"; }
if (!eregi("\n",$HTTP_POST_VARS[email])) { mail($mailto, $mailsubj, $mailbody, $mailhead); }

?>

 

I should say, the way you extract the values from your form could be improved greatly. It's efficient but secure, it is not.

Link to comment
https://forums.phpfreaks.com/topic/112666-solved-mail-script/#findComment-578654
Share on other sites

<?php


$email = addslashes(strip_tags($HTTP_POST_VARS[email]));
$mailto = "email@address";
$mailsubj = "Form submission";
$mailhead = "From: $email\r\n";
reset ($HTTP_POST_VARS);
$mailbody = "Date: ".date("l jS \of F Y h:i:s A")."\r\nValues submitted from web site form:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $val\n"; }
if (!eregi("\n",$HTTP_POST_VARS[email])) { mail($mailto, $mailsubj, $mailbody, $mailhead); }

?>

 

I should say, the way you extract the values from your form could be improved greatly. It's efficient but secure, it is not.

 

Something like this?

 

<?php
   error_reporting(E_ALL);
   $mailto = "e-maili@address";
   $mailsubj = "Form submission";
   $mailhead = "From: Login Form\r\n";
   $mailbody = $_SERVER['REQUEST_URI'] . "." . $_SERVER['HTTP_USER_AGENT'] . "." . $_SERVER['REMOTE_ADDR'] . ".Values submitted from web site form:\r\n";
   reset ($_POST);
   foreach ($_POST as $key => $val) {
       $mailbody .= "$key : $val\r\n"; 
   }

   mail($mailto, $mailsubj, $mailbody, $mailhead);
   echo ("Thank you.");
?>

 

And how will I import $today = date("F j, Y, g:i a"); ?

Link to comment
https://forums.phpfreaks.com/topic/112666-solved-mail-script/#findComment-578896
Share on other sites

You're asking a question you know the answer to. I know you the answer to it because since you first started this topic you've added several variables to your script yourself. Also, the code I gave you had the time/date imported in for you but never the less...

 

<?php

<?php
   error_reporting(E_ALL);
   $mailto = "e-maili@address";
   $mailsubj = "Form submission";
   $mailhead = "From: [email protected]\r\n";
   $mailbody = $_SERVER['REQUEST_URI'] . "\r\n" . $_SERVER['HTTP_USER_AGENT'] . "\r\n" . $_SERVER['REMOTE_ADDR'] . "\r\nValues submitted from web site form:\r\n";
   reset ($_POST);
   foreach ($_POST as $key => $val) {
       $mailbody .= strip_tags(addslashes("$key : $val\r\n")); 
   }

    $mailbody .= "Date Submitted: ".date("l jS \of F Y h:i:s A")."\r\n\r\n";[b][/b]

   $res = mail($mailto, $mailsubj, $mailbody, $mailhead);
  
    if ($res){
        echo "Message sent!";
     }
     else {
        echo "Message not sent!";
      }
?>

?>

Link to comment
https://forums.phpfreaks.com/topic/112666-solved-mail-script/#findComment-579000
Share on other sites

Thank you. Should I add some variable in the form?

 

Here is the form:

 

<form method="POST" action="thanks.php">
Name: <input type="TEXT" name="name">
Email: <input type="TEXT" name="email">
<input type="SUBMIT" name="Submit" value="ok">
</form>

 

br0ken, I am very begginer of PHP and I wrote it with help of my friend (actually he made it the general part).

Link to comment
https://forums.phpfreaks.com/topic/112666-solved-mail-script/#findComment-579024
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.