I want to generate a reference number based on the time and date the form was completed, and I want to include the reference number in the email to owner, in the autoresponder message to the customer, and to mysql. The problem is, I'm not sure how to implement this reference number string into my PHP file.
Here is the reference number code:
$reference_num_date = date("ymdHis",$reference_num_secs);
for example the code above would return 080601154542
in other words:
01 Jun 2008 15:45:42
Here is my current PHP code without the reference number code:
<?php
# ----------------------------------------------------
# -----
# ----- This script was generated by php form magic 1.1 on 5/29/2008 at 8:03:00 PM
# -----
# -----
http://www.websitedatabases.com
# -----
# ----------------------------------------------------
// Receiving variables
@$fname = addslashes($_POST['fname']);
@$lname = addslashes($_POST['lname']);
@$email = addslashes($_POST['email']);
@$phone = addslashes($_POST['phone']);
@$property = addslashes($_POST['property']);
@$requestor = addslashes($_POST['requestor']);
@$city = addslashes($_POST['city']);
@$servicer = addslashes($_POST['servicer']);
@$state = addslashes($_POST['state']);
@$liens = addslashes($_POST['liens']);
@$zip = addslashes($_POST['zip']);
@$loanstatus = addslashes($_POST['loanstatus']);
// Validation
if (strlen($fname) == 0 )
{
header("Location: error.html");
exit;
}
if (strlen($lname) == 0 )
{
header("Location: error.html");
exit;
}
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
{
header("Location: error.html");
exit;
}
if (strlen($email) == 0 )
{
header("Location: error.html");
exit;
}
if (strlen($phone) <10)
{
header("Location: error.html");
exit;
}
if (strlen($phone) >15)
{
header("Location: error.html");
exit;
}
if (strlen($phone) == 0 )
{
header("Location: error.html");
exit;
}
if (strlen($property) == 0 )
{
header("Location: error.html");
exit;
}
if ( strcasecmp($requestor,"Realtor") != 0 && strcasecmp($requestor,"Homeowner") != 0 )
{
header("Location: error.html");
exit;
}
if (strlen($requestor) == 0 )
{
header("Location: error.html");
exit;
}
//Sending Email to form owner
# Email to Owner
$pfw_subject = "New Negotiation Request";
$pfw_email_to = "";
$pfw_message = "fname: $fname\n"
. "lname: $lname\n"
. "email: $email\n"
. "phone: $phone\n"
. "requestor: $requestor\n"
. "property: $property\n"
. "city: $city\n"
. "state: $state\n"
. "zip: $zip\n"
. "servicer: $servicer\n"
. "liens: $liens\n"
. "loanstatus: $loanstatus\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
//Sending auto respond Email to user
# Email to Owner
$pfw_header = "From: ";
$pfw_subject = "Negotiation Request Confirmation";
$pfw_email_to = "$email";
$pfw_message = "Hi $fname,\n"
. "Your negotiation request has been received, and you will receive a phone call within the next 24 hours. In most cases a short sale specialist will get back to you within the same day. \n"
. "\n"
. "We will gather some additional information, walk you through the short sale process, and answer any questions you have.\n"
. "\n"
. "In the meantime, please gather the loan numbers for each lien so we can get started as soon as possible.\n"
. "\n"
. "Just to recap, here is the information you submitted:\n"
. "\n"
. "Your name: $fname $string = strtolower($string);
$string = substr_replace($string, strtoupper(substr($string, 0, 1)), 0, 1);$lname\n"
. "Your Phone Number: $phone\n"
. "You are a: $requestor\n"
. "Property Address: $property\n"
. "Property City: $city\n"
. "Property State: $state\n"
. "Property Zip: $zip\n"
. "Mortgage Servicer: $servicer\n"
. "Any Additional Liens: $liens\n"
. "Loan Status: $loanstatus\n"
. "\n"
. "We look forward to talking to you soon. \n"
. "\n"
. "Sincerely,\n"
. "The Simply Short Sales Team\n"
. "www.simplyshortsales.com\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
//saving record to MySQL database
@$pfw_strQuery = "INSERT INTO `negrequest`(`fname`,`lname`,`email`,`phone`,`prop erty`,`requestor`,`city`,`servicer`,`state`,`liens `,`zip`,`loanstatus`)VALUES (\"$fname\",\"$lname\",\"$email\",\"$phone\",\"$pr operty\",\"$requestor\",\"$city\",\"$servicer\",\" $state\",\"$liens\",\"$zip\",\"$loanstatus\")" ;
@$pfw_host = "mysql";
@$pfw_user = "prodempsey";
@$pfw_pw = "1234jack";
@$pfw_db = "simplyshortsales";
$pfw_link = mysql_connect($pfw_host, $pfw_user, $pfw_pw);
if (!$pfw_link) {
die('Could not connect: ' . mysql_error());
}
$pfw_db_selected = mysql_select_db($pfw_db, $pfw_link);
if (!$pfw_db_selected) {
die ('Can not use $pfw_db : ' . mysql_error());
}
//insert new record
$pfw_result = mysql_query($pfw_strQuery);
if (!$pfw_result) {
die('Invalid query: ' . mysql_error());
}
mysql_close($pfw_link);
header("Location: thankyou.html");
?>