Hello,
I have a form that people use to sign up for a news letter all of the field in this form are required.
I use the trim() to get rid of any white space and to make sure that they didnt just enter in a bunch of spaces and so on...
The problem I am having is that even though I have all the fields validated the phone and country fields dont always go into the MySQL database and I dont always get an email telling me that someone has signed up. So I could go days not knowing anyone has signed up and then to come to find out the country and phone number didnt take anyways. I need that information because the company I work for treats all these sign ups as sales leads..
This is one of my earlier scripts so Im sure it needs some type of updating.
here is my code:
<?php
session_start();
include("../forms/open_config.php");
//post form variables and trim any white space off of them.
$Name = $_POST['Name'];
$Name = trim($Name);
$Company = $_POST['Company'];
$Company = trim($Company);
$country = $_POST['country'];
$country = trim($country);
$Phone = $_POST['Phone'];
$Phone = trim($Phone);
$Email = $_POST['Email'];
$Email = trim($Email);
$Date = $_POST['Date'];
$Last = $_POST['Last'];
$Last = trim($Last);
$so_email = "info@sono-tek.com";
$compannounce = $_POST['compannounce'];
$newpro = $_POST['newpro'];
session_register("Name");
session_register("Last");
session_register("Company");
session_register("Phone");
session_register("Email");
if (empty($compannounce) && empty($newpro)) {
$newpro = '1';
}
if($compannounce == 1) {
$compannounceText = "Corporate Announcements";
}
if($newpro == 1) {
$newproText = "New Products";
}
if (isset($_POST['txtNumber'])) {
$number = $_POST['txtNumber'];
if(empty($Name) || $Name == " ") {
$nameerror = "You must provide your name";
} else {
$nameerror = NULL;
}
if(empty($Company) || $Company == " ") {
$comperror = "You must provide a company name";
} else {
$comperror = NULL;
}
if(empty($country) || $country == " ") {
$countryError = "Please enter your country";
} else {
$countryError = NULL;
}
if(empty($Phone) || $Phone == " " || $Phone == "000-000-0000" ) {
$phoneerror = "You must provide a phone number";
} else {
$phoneerror = NULL;
}
if(empty($Last) || $Last == " ") {
$lasterror = "You must provide your last name";
} else {
$lasterror = NULL;
}
if (check_email_address($Email) ) {
$emailformaterror = NULL;
} else {
$emailerror = "Please enter a valid email address";
}
if(($nameerror == NULL && $comperror == NULL && $phoneerror == NULL && $countryError == NULL) && ($emailerror == NULL && $lasterror == NULL && md5($number) == $_SESSION['image_random_value'])){
$sql_insert = "INSERT INTO newsletter (name, lastName, company, phone, email, corpAnnounce, newPro, date, country) VALUES ('$Name','$Last','$Company','$Phone','$Email','$compannounce','$newpro','$Date','$country')";
mysql_query($sql_insert);
$subject = "Sono-Tek Newsletter Confirmation";
$confirm_body = '<html><body>Hello ' . $Name . ',<br />Thank you for signing up for the Sono-Tek newsletter. You will receive your first news letter very shortly. If you did not sign up for this service please follow the provided link to remove your information from our list. Thank you again.<br />Remove me from the list:<br /><a href="http://www.sono-tek.com/newsletter/remove.php">http://www.sono-tek.com/newsletter/remove.php</a></body></html>';
//alert notifies sono-tek employee of a sign up
$alert = '<html><body>' . $Date . '<br />' . $Name . ' ' . $Last . ' from ' . $Company . ' has signed up for the News Letter<br />Email: ' . $Email . '<br />Phone: ' . $Phone . '<br />Country: '. $country .'<br />Newsletter Types:'. $compannounceText .' and '. $newproText .'<br />';
//Headers
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: Sono-Tek Corporation <$so_email>";
//email to sono-tek addresses
//$emailSono = "cycorda@sono-tek.com,abruce@sono-tek.com";
$emailSono = "websupport@sono-tek.com";
mail($emailSono,$subject,$alert,$headers);
mail($Email,$subject,$confirm_body,$headers);
//mail($so_email,$subject,$alert,$headers);
header("location:http://www.sono-tek.com/newsletter/letterThanks.php");
} else {
$validerror = "Please enter the correct validation number";
}
}
If anyone can help I would really appreciate it. Thanks.