ragazzi quando un utente scrive i suoi dati mi arriva un email con i suoi dati, vorrei mettere l'ora di quando mi ha inviato l'email. grazie mille
Codice PHP:
codice php
<?php
//Includes user settings
include('config.php');
session_start();
$name = $_POST['name'];
$email = $_POST['email'];
$tel = $_POST['tel'];
$human = $_POST['humancheck'];
$message = $_POST['message'];
$callback = $_POST['callback'];
$subject = $_POST['subject'];
$ip = $_SERVER['REMOTE_ADDR'];
$error = false;
//Reset error messages
$_SESSION['emailerror'] = "";
$_SESSION['nameerror'] = "";
$_SESSION['subjecterror'] = "";
$_SESSION['messageerror'] = "";
$_SESSION['humanerror'] = "";
$_SESSION['senderror'] = "";
//Validation Session Variables
$_SESSION['message'] = $message;
$_SESSION['tel'] = $tel;
$_SESSION['name'] = $name;
$_SESSION['email'] = $email;
$_SESSION['subject'] = $subject;
//Validation
if($name == ""){
$_SESSION['nameerror'] = "Please type your name.";
$error = true;
}
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
$_SESSION['emailerror'] = "Please check your email is valid.";
$error = true;
}
if($email == ""){
$_SESSION['emailerror'] = "Please type in an email address.";
$error = true;
}
if($subject == ""){
$_SESSION['subjecterror'] = "Please give a subject.";
$error = true;
}
if($message == ""){
$_SESSION['messageerror'] = "Please type a message.";
$error = true;
}
if($human != "yes"){
$error = true;
$_SESSION['humanerror'] = "Please select yes.";
}
if($error == true) {
$_SESSION['senderror'] = "There are some incorrect or missing fields in the form!";
header("Location: $contactpage");
exit;
} else {
$to = $youremail;
$sbj = "You have recieved a message - ContactKing";
$msg = "
<html>
<head>
<style type='text/css'>
body{
font-family:'Lucida Grande', Arial;
color:#333;
font-size:15px;
}
</style>
</head>
<body>
<img src='"."$logo"."' width='255' height='124' alt='contact' />
<table width='600' border='0' cellspacing='0' cellpadding='5'>
<tr>
<td width='121' align='right' valign='baseline'><strong>Name:</strong></td>
<td width='459'>$name</td>
</tr>
<tr>
<td align='right' valign='baseline'><strong>Email:</strong></td>
<td>$email</td>
</tr>
<tr>
<td align='right' valign='baseline'><strong>IP:</strong></td>
<td>$ip</td>
</tr>
<tr>
<td align='right' valign='baseline'><strong>Contact Number:</strong></td>
<td>$tel</td>
</tr>
<tr>
<td align='right' valign='baseline'><strong>Call back?:</strong></td>
<td>$callback</td>
</tr>
<tr>
<td align='right' valign='baseline'><strong>Subject:</strong></td>
<td>$subject</td>
</tr>
<tr>
<td align='right' valign='baseline'><strong>Message:</strong></td>
<td>$message</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><small>Powered by ContactKing | © Copyright 2010 creativeben.co.uk</small></td>
</tr>
</table>
</body>
</html>
";
$from = $email;
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: $from";
mail($to,$sbj,$msg,$headers); //Send to you.
//END OF EMAIL TO ME
//START EMAIL CONFIRMATION
$toClient = $email;
$msgClient = "
<html>
<head>
<style type='text/css'>
body{
font-family:'Lucida Grande', Arial;
color:#333;
font-size:15px;
}
</style>
</head>
<body>
<img src='"."$logo"."' width='255' height='124' alt='contact' />
<table width='600' border='0' cellspacing='0' cellpadding='5'>
<tr>
<td width='117' align='right' valign='baseline'><strong>Thank you,</strong></td>
<td width='463'>$name</td>
</tr>
<tr>
<td> </td>
<td>We have recieved your message and will get back to you as soon as possible.</td>
</tr>
<tr>
<td> </td>
<td><small>Powered by ContactKing | © Copyright 2010 creativeben.co.uk</small></td>
</tr>
</table>
</body>
</html>
";
$fromClient = $email;
$sbjClient = "Thank you, $name - $yourwebsite";
$headersClient = 'MIME-Version: 1.0' . "\r\n";
$headersClient .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headersClient .= "From: $fromClient";
mail($toClient,$sbjClient,$msgClient,$headersClient); //Send to Client.
//END EMAIL CONFIRMATION
//Reset error messages
$_SESSION['emailerror'] = "";
$_SESSION['nameerror'] = "";
$_SESSION['subjecterror'] = "";
$_SESSION['messageerror'] = "";
$_SESSION['humanerror'] = "";
$_SESSION['senderror'] = "";
//Reset Validation Session Variables
$_SESSION['message'] = "";
$_SESSION['tel'] = "";
$_SESSION['name'] = "";
$_SESSION['email'] = "";
$_SESSION['subject'] = "";
session_destroy();
header("Location: $thankyoupage");
exit;
}
?>