Reset password link not working - php

I have a reset password link that seemingly won't process $_GET('variable'). The forgot password form:
<?php
$error = $email = "";
if (isset($_POST['email']))
{
$email = sanitizeString($_POST['email']);
$com_code = md5(uniqid(rand()));
if ($email == "")
$error = "Not all fields were entered<br>";
else if (!filter_var($email, FILTER_VALIDATE_EMAIL))
$error='Email is invalid';
else
{
$resultE = queryMySQL("SELECT email FROM users WHERE email='$email'");
if ($resultE->num_rows == 0)
{
$error = "<span class='error'>Email
error</span><br><br>";
}else
{
queryMysql("UPDATE users SET com_code='$com_code' WHERE email='$email'");
$mail_to = $email;
$subject = 'Reset your password ';
$body_message = 'Please click on this link to reset password ';
$body_message .= 'Activate';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if(isset($_SESSION['url']))
$url = $_SESSION['url'];
else
$url = "../../index.php";
header("Location:$url");
}
}
}
?>
The reset password form:
<?php
$error = $pass ="";
if (isset($_POST['pass']))
{
$pass = sanitizeString($_POST['pass']);
$salt1 = "qm&h*";
$salt2 = "pg!#";
$token = hash('ripemd128', "$salt1$pass$salt2");
$passkey = $_GET['passkey'];
if ($pass == "")
$error = "Enter all fields";
//put if else statements here
else if (preg_match("/[^a-zA-Z0-9_-]/", $pass)){
$error='Remove spaces,numbers,special characters';
}
else
{
$resultpassw = queryMysql("SELECT * FROM users WHERE com_code='$passkey' ");
if ($resultpassw->num_rows == 0)
$error = " ✘ Confirmation not sent";
else
{
queryMysql("UPDATE users SET pass='$token', updated=CURRENT_TIMESTAMP WHERE com_code='$passkey'");
header("Location:../../profile.php");
}
}
}
?>
The error that keeps occurring is the 'confirmation not sent' implying that the table 'users' has no com_code inserted previously, but when I look at the table via phpmyadmin the com_code is there. Where I'm I going wrong

In forgot passaword form try below.
<?php
$error = $email = "";
if (isset($_POST['email']))
{
$email = sanitizeString($_POST['email']);
$com_code = md5(uniqid(rand()));
if ($email == "")
$error = "Not all fields were entered<br>";
else if (!filter_var($email, FILTER_VALIDATE_EMAIL))
$error='Email is invalid';
else
{
$resultE = queryMySQL("SELECT email FROM users WHERE email='$email'");
if ($resultE->num_rows == 0)
{
$error = "<span class='error'>Email
error</span><br><br>";
}else
{
queryMysql("UPDATE users SET com_code='$com_code' WHERE email='$email'");
$mail_to = $email;
$subject = 'Reset your password ';
$body_message = 'Please click on this link to reset password ';
$body_message .= 'Activate';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if(isset($_SESSION['url']))
$url = $_SESSION['url'];
else
$url = "../../index.php";
header("Location:$url");
}
}
}
?>
I changed one line here.
$body_message .= 'Activate';
As $com_code is dynamic value so you need to pass it in way, so php can fetch its value, and not take it as a static value.

Think I'll just use sessions. forgot_pass.php:
$com_code = md5(uniqid(rand()));
$_SESSION["com_code_sesh"] = $com_code;
reset_pass.php:
$passkey = $_SESSION["com_code_sesh"];

Related

How do I redirect to a page after Contact form is submitted?

All is working fine, except redirect to the thank you page. I can send mail both sides, but after contact form is submitted I can't redirect the page to thankyou.html Am I doing something wrong in the code?
session_start();
$serverMail = 'example#gmail.com';
$email = isset($_POST['email']) ? $_POST['email'] : '';
$name = isset($_POST['name']) ? $_POST['name'] : '';
$message = isset($_POST['message']) ? $_POST['message'] : '';
$captcha = isset($_POST['captcha']) ? $_POST['captcha'] : '';
$img_session = isset($_SESSION['img_session']) ? $_SESSION['img_session'] : '';
$website = $_SERVER['mysite'];
$headers = "From: $serverMail\r\n";
$toAdmin = "some example";
$toGuest = "some example";
if(empty($email) or empty($name) or empty($email) or empty($message)){
$output = "All fields are required!";
}
else{
//to server side
if(md5($captcha) == $img_session){
$mailMessage = "
$name
some message";
if (mail($serverMail, $toAdmin, $mailMessage, $headers)) {
}
}
// to guests side
if(md5($captcha) == $img_session){
$mailMessage = "
$name
some message";
if (mail($email, $toGuest, $mailMessage, $headers)) {
header('Location:https://stackoverflow.com/');
exit();
}
}
else{
$output = "Wrong Captcha Code!";
}
}
echo $output;
I have to if(md5($captcha) == $img_session) because $mailMessage are different.
There is no need to test the captcha twice.
Once the captcha is checked, build and send both emails, keeping the status in a temp variable. Once the 2 emails are sent check the status of both and code accordingly for picking up the error whereever it is found.
session_start();
$serverMail = 'example#gmail.com';
$email = isset($_POST['email']) ? $_POST['email'] : '';
$name = isset($_POST['name']) ? $_POST['name'] : '';
$message = isset($_POST['message']) ? $_POST['message'] : '';
$captcha = isset($_POST['captcha']) ? $_POST['captcha'] : '';
$img_session = isset($_SESSION['img_session']) ? $_SESSION['img_session'] : '';
$website = $_SERVER['mysite'];
$headers = "From: $serverMail\r\n";
$toAdmin = "some example";
$toGuest = "some example";
if(empty($email) or empty($name) or empty($email) or empty($message)){
$output = "All fields are required!";
} else{
if(md5($captcha) == $img_session){
//to server side
$mailMessage = "\n$name\n\nsome message";
$m1 = mail($serverMail, $toAdmin, $mailMessage, $headers)) {
// to guests side
$mailMessage = "\n$name\n\nsome other message";
$m2 = mail($email, $toGuest, $mailMessage, $headers)) {
if ( $m1 && $m2 ) {
header('Location:https://stackoverflow.com/');
exit;
} else {
// one or both emails failed to send
if( ! $m1 ) {
// error message for server mail failure
}
if ( ! $m2 ) {
// error message for guest mail failure
}
} else {
$output = "Wrong Captcha Code!";
}
}
echo $output;
Try using this code, if it doesnt give try using a different browsers. it may be from the
echo '<META HTTP-EQUIV="refresh" CONTENT="0;url=http://helloworld/contact/thankyou.html">';
Because you use "exit" after the first mail!

how to store somthing from session

I have a login system in my site. in which session starts when user login. when a user sign up his information is stored in userdb.php .now i want to store point of the user when he clicks link www.stackoverflow.com and save it to my database or userdb.php.and again display point.
my sign up code are
<?php
if (session_id() == "")
{
session_start();
}
$database = './usersdb.php';
$success_page = './Inside.php';
$error_message = "";
if (!file_exists($database))
{
die('User database not found!');
exit;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['form_name'] == 'signupform')
{
$newusername = $_POST['username'];
$newemail = $_POST['email'];
$newpassword = $_POST['password'];
$confirmpassword = $_POST['confirmpassword'];
$newfullname = $_POST['fullname'];
$code = 'NA';
if ($newpassword != $confirmpassword)
{
$error_message = 'Password and Confirm Password are not the same!';
}
else
if (!preg_match("/^[A-Za-z0-9_!#$]{1,50}$/", $newusername))
{
$error_message = 'Username is not valid, please check and try again!';
}
else
if (!preg_match("/^[A-Za-z0-9_!#$]{1,50}$/", $newpassword))
{
$error_message = 'Password is not valid, please check and try again!';
}
else
if (!preg_match("/^[A-Za-z0-9_!#$.' &]{1,50}$/", $newfullname))
{
$error_message = 'Fullname is not valid, please check and try again!';
}
else
if (!preg_match("/^.+#.+\..+$/", $newemail))
{
$error_message = 'Email is not a valid email address. Please check and try again.';
}
else
if (isset($_POST['captcha'],$_SESSION['random_txt']) && md5($_POST['captcha']) == $_SESSION['random_txt'])
{
unset($_POST['captcha'],$_SESSION['random_txt']);
}
else
{
$error_message = 'The entered code was wrong.';
}
$items = file($database, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach($items as $line)
{
list($username, $password, $email, $fullname) = explode('|', trim($line));
if ($newusername == $username)
{
$error_message = 'Username already used. Please select another username.';
break;
}
}
if (empty($error_message))
{
$file = fopen($database, 'a');
fwrite($file, $newusername);
fwrite($file, '|');
fwrite($file, md5($newpassword));
fwrite($file, '|');
fwrite($file, $newemail);
fwrite($file, '|');
fwrite($file, $newfullname);
fwrite($file, '|1|');
fwrite($file, $code);
fwrite($file, "\r\n");
fclose($file);
$subject = 'Your new account';
$message = 'A new account has been setup.';
$message .= "\r\nUsername: ";
$message .= $newusername;
$message .= "\r\nPassword: ";
$message .= $newpassword;
$message .= "\r\n";
$header = "From: webmaster#yourwebsite.com"."\r\n";
$header .= "Reply-To: webmaster#yourwebsite.com"."\r\n";
$header .= "MIME-Version: 1.0"."\r\n";
$header .= "Content-Type: text/plain; charset=utf-8"."\r\n";
$header .= "Content-Transfer-Encoding: 8bit"."\r\n";
$header .= "X-Mailer: PHP v".phpversion();
mail($newemail, $subject, $message, $header);
header('Location: '.$success_page);
exit;
}
}
?>
Please help me.....
You could try it by using ajax..if you want save points..
like you have a link
www.stackoverflow.com
Now in your js file:
$('#stack-overflow').on('click', function() {
count = 1//how many points you want to assign
//send a ajax
$.ajax({
url:'usersdb.php',
type:'GET'
dataType: 'json'
data: {
points: count,
},
success: function(resp){
$('#stack-overflow').href='www.stackoverflow.com';
//now triggered this link
$('#stack-overflow').click();
//or what ever msg you want to display
});
});
//Now u can get $_POST values in your usersdb.php and save it
if there is another issue the please confirm...and tell me what actually you want.
Thanks.
To store values in session you can just use the below syntax
$_SESSION['Desired variable name'] = value;

It wont send the message (EMAIL)PHP [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 8 years ago.
i dont know why it wont send it just echo's this msg Oops.. There seems to be a technical errorWe are truly sorry, please check again later
i dont know whats the problem maybe i'm overlooking,
can u pls tell me i have i gone wrong.
if you need the html code let me know
suggestions on how to improve this code would be gratefully appreciated :)
PHP CODE:
<?php
function clean($str)
{
$str = mysql_real_escape_string($str);
$str = htmlspecialchars($str);
$str = strip_tags($str);
return($str);
}
if(isset($_POST['name']) &&
isset($_POST['address']) &&
isset($_POST['hp']) &&
isset($_POST['email']) &&
isset($_POST['rm']) &&
isset($_POST['service']) &&
isset($_POST['name-owner']) &&
isset($_POST['name-rep']) &&
isset($_POST['contract-from']) &&
isset($_POST['contract-to']) &&
isset($_POST['agree']) &&
isset($_POST['submit'])){
$name = clean($_POST['name']);
if($name == NULL || $name == "")
{
die ("Please enter your name");
$errormsg = "<button class=\"\" onClick=\"history.go(-1)\"> Retry</button> ";
}
$address = clean($_POST['address']);
if($address == NULL)
{
die ("Please enter your Business address");
$errormsg;
}
$hp = clean($_POST['hp']);
if($hp == NULL)
{
die ("Please enter your Phone No.");
}
$email = clean($_POST['email']);
if($email == NULL)
{
die ("Please enter your Email address");
$errormsg;
}
$url = clean($_POST['url']);
$rm = clean($_POST['rm']);
if($rm == NULL)
{
die ("Please enter your Amount/Percentage");
$errormsg;
}
$service = clean($_POST['service']);
if($service == NULL)
{
die ("Please enter your Service/Item offer");
$errormsg;
}
$nameowner = clean($_POST['name-owner']);
if($nameowner == NULL)
{
die ("Please enter the Name of Owner/Manager");
$errormsg;
}
$namerep = clean($_POST['name-rep']);
if($namerep == NULL)
{
die ("Please enter the Name of Representative");
$errormsg;
}
$contract_from = clean($_POST['contract-from']);
if($contract_from == NULL)
{
die ("Please enter the Contract date");
$errormsg;
}
$contract_to = clean($_POST['contract-to']);
if($contract_to == NULL)
{
die ("Please enter the Contract date");
$errormsg;
}
$agree = clean($_POST['agree']);
$message = "Business Name: ".$name."\r\n";
$message = "Business Address: " .$address. "\r\n";
$message = "Phone No.: ".$hp."\r\n";
$message = "Email: ".$email."\r\n";
$message = "URL: <a href=\"".$url."\"\r\n ";
$message = "Amount/Percentage offer: ".$rm."\r\n";
$message = "Items/Service offer:".$service."\r\n";
$message = "Name of Owner/Manager".$nameowner."\r\n";
$message = "Name of Representative".$namerep."\r\n";
$message = "This contract is valid for one(1) year from: <b>".$contract_from."</b> to <b>".$contract_to."</b> \r\n";
$message = $agree."\r\n";
$to = 'contact#example.com';
$subject = 'Contact query';
$headers = 'From:' . "$email \r\n" .
'Reply-To:' . "$email \r\n" .
'X-Mailer: PHP/' . phpversion();
$send = mail($to, $subject, $message, $headers);
if ($send == TRUE)
{
echo "<p>Message has been sent</p>";
echo "<p>Thank you</p>";
}
else
{
die ("<p>Message failed to send</p>");
}
}else {
echo "<p>Oops.. There seems to be a technical error<br>We are truly sorry, please check again later</p>";
}
?>
Probably one of the POST Variable is not set and thus it might throw you to the else part to show the error
You must attach the require_once "Mail.php"; require_once('Mail/mime.php'); into your code so that the function works for you
<?php
function clean($str)
{
$str = mysql_real_escape_string($str);
$str = htmlspecialchars($str);
$str = strip_tags($str);
return($str);
}
if(isset($_POST['submit']))
{
$name = clean($_POST['name']);
if($name == NULL || $name == "")
{
die ("Please enter your name");
$errormsg = "<button class=\"\" onClick=\"history.go(-1)\"> Retry</button> ";
}
$address = clean($_POST['address']);
if($address == NULL)
{
die ("Please enter your Business address");
$errormsg;
}
$hp = clean($_POST['hp']);
if($hp == NULL)
{
die ("Please enter your Phone No.");
}
$email = clean($_POST['email']);
if($email == NULL)
{
die ("Please enter your Email address");
$errormsg;
}
$url = clean($_POST['url']);
$rm = clean($_POST['rm']);
if($rm == NULL)
{
die ("Please enter your Amount/Percentage");
$errormsg;
}
$service = clean($_POST['service']);
if($service == NULL)
{
die ("Please enter your Service/Item offer");
$errormsg;
}
$nameowner = clean($_POST['name-owner']);
if($nameowner == NULL)
{
die ("Please enter the Name of Owner/Manager");
$errormsg;
}
$namerep = clean($_POST['name-rep']);
if($namerep == NULL)
{
die ("Please enter the Name of Representative");
$errormsg;
}
$contract_from = clean($_POST['contract-from']);
if($contract_from == NULL)
{
die ("Please enter the Contract date");
$errormsg;
}
$contract_to = clean($_POST['contract-to']);
if($contract_to == NULL)
{
die ("Please enter the Contract date");
$errormsg;
}
$agree = clean($_POST['agree']);
$message = "Business Name: ".$name."\r\n";
$message = "Business Address: " .$address. "\r\n";
$message = "Phone No.: ".$hp."\r\n";
$message = "Email: ".$email."\r\n";
$message = "URL: <a href=\"".$url."\"\r\n ";
$message = "Amount/Percentage offer: ".$rm."\r\n";
$message = "Items/Service offer:".$service."\r\n";
$message = "Name of Owner/Manager".$nameowner."\r\n";
$message = "Name of Representative".$namerep."\r\n";
$message = "This contract is valid for one(1) year from: <b>".$contract_from."</b> to <b>".$contract_to."</b> \r\n";
$message = $agree."\r\n";
$to = 'contact#example.com';
$subject = 'Contact query';
$headers = 'From:' . "$email \r\n" .
'Reply-To:' . "$email \r\n" .
'X-Mailer: PHP/' . phpversion();
$send = mail($to, $subject, $message, $headers);
if ($send == TRUE)
{
echo "<p>Message has been sent</p>";
echo "<p>Thank you</p>";
}
else
{
die ("<p>Message failed to send</p>");
}
}
else
{
echo "<p>Oops.. There seems to be a technical error<br>We are truly sorry, please check again later</p>";
}
?>

My PHP form is sending random blank emails?

I have a application form on my website and when someone fills one out it works fine with all data properly sent over, however multiple times a day we are getting completely blank emails. (client is CONVINCED that its people filling out the form and its sending it blank randomly removing their information - i dont think thats possible)
Here are snippets of my code:
if($_SERVER['REQUEST_METHOD'] == "POST") {
if (trim($_POST['fname']) == "") {
$errors[] = "Please enter your first name";
}
if (trim($_POST['lname']) == "") {
$errors[] = "Please enter your last name";
}
if (trim($_POST['address1']) == "") {
$errors[] = "Please enter your address";
}
if (trim($_POST['city']) == "") {
$errors[] = "Please enter your city";
}
if (trim($_POST['state']) == "") {
$errors[] = "Please enter your state";
}
if (trim($_POST['zip']) == "") {
$errors[] = "Please enter your zip code";
}
if (trim($_POST['email']) == "") {
$errors[] = "Please enter your email";
}
if (trim($_POST['phone']) == "") {
$errors[] = "Please enter your phone number";
}
if (trim($_POST['school']) == "") {
$errors[] = "Please enter your High School";
}
if (trim($_POST['school_study']) == "") {
$errors[] = "Please enter your course of study";
}
if (trim($_POST['school_years']) == "") {
$errors[] = "Please enter your school years completed";
}
if (trim($_POST['school_degree']) == "") {
$errors[] = "Please enter your diploma/degree";
}
if (trim($_POST['employer1']) == "") {
$errors[] = "Please enter Employer #1";
}
if (trim($_POST['employer1_telephone']) == "") {
$errors[] = "Please enter Employer #1 Telephone";
}
if (trim($_POST['employer1_title']) == "") {
$errors[] = "Please enter Employer #1 Title";
}
if (trim($_POST['employer1_supervisor']) == "") {
$errors[] = "Please enter Employer #1 Supervisor";
}
if (trim($_POST['employer1_from']) == "") {
$errors[] = "Please enter Employer #1 Start Date";
}
if (trim($_POST['employer1_to']) == "") {
$errors[] = "Please enter Employer #1 End Date";
}
if (trim($_POST['employer1_salary']) == "") {
$errors[] = "Please enter Employer #1 Salary";
}
if (trim($_POST['employer1_duties']) == "") {
$errors[] = "Please enter Employer #1 Duties";
}
if (trim($_POST['sig2']) == "") {
$errors[] = "Please complete the Signature Field";
}
if (trim($_POST['date2']) == "") {
$errors[] = "Please complete the Date Field";
}
if(is_array($errors))
{
echo '<div class="error"><span>The following errors occurred:</span><ul>';
while (list($key,$value) = each($errors))
{
echo '<li>'.$value.'</li><br />';
}echo'</ul></div>';
}
else {
require_once('recaptchalib.php');
$privatekey = "(private key thing here not sure if that should be shared)";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
// convert the application to a pdf. not going to include all this jarble
// also insert the application into a database - not including
$mpdf=new mPDF();
$mpdf->WriteHTML($html);
$content = $mpdf->Output('', 'S');
$content = chunk_split(base64_encode($content));
$eol = PHP_EOL;
$mailto = "$setting[apps_email]";
$from_name = 'Employment Application';
$from_mail = 'no-reply';
$replyto = 'no-reply';
$uid = md5(uniqid(time()));
$subject = "".$row[fname]." ".$row[lname]." - ".$row1[position]."";
$filename = "".$row[fname]."".$row[lname]."-".$row[submitted].".pdf";
$header = "From: ".$from_name." <".$from_mail.">".$eol;
$header .= "Reply-To: ".$replyto.$eol;
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"".$eol;
$header .= "Content-Transfer-Encoding: 7bit".$eol;
$message .= "--".$uid.$eol;
$message .= "Content-type:text/plain; charset=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$message .= $eol."".$row[fname]." ".$row[lname]." has submitted an employment application for the ".$row1[position]." position. Please see the attached .pdf file to save and/or print the application.".$eol;
$message .= "--".$uid.$eol;
$message .= "Content-Type: application/pdf; name=\"".$filename."\"\r\n";
$message .= "Content-Transfer-Encoding: base64\r\n";
$message .= "Content-Disposition: attachment".$eol.$eol;
$message .= $eol.$content;
$message .= "--".$uid."--".$eol;
$is_sent = #mail($mailto, $subject, $message, $header);
}
}}
I feel like i've taken every measure against this with making sure it was submitted first, validating required fields, and i even threw on a stupid captcha that i hate doing
any idea why (i'm assuming crawlers) are sending blank emails?

Form validation and captcha

I have two issues with a contact form I have created. I was previously hit hard by spam.
I am requiring that all fields be filled out before the form is processed, but what I have written isn't working: info goes into the database whether a person fills out all fields or not. ***fixed by using:
function validateForm()
{
var x=document.forms["validation"]["firstname"].value;
if (x==null || x=="")
{
alert("Please enter your first name");
return false;
}
for all fields and this one for email:
var x=document.forms["validation"]["email"].value;
var atpos=x.indexOf("#");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Please enter a valid email address");
return false;
}
Now, I need to get the captcha working or how to add to check if captcha is correct in same javascript? I think the error lies in this somehow?:
session_start();
if($_POST['submitted'] == "contactus")
if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) {
header("Location:http://www.berrieswebdesign.com/thankyou.php?message=thanks");
unset($_SESSION['security_code']);
} else {
// Insert your code for showing an error message here
echo "<div id='thankyoubox'>'Security breach! Security Breach! Ehem...Your security code was incorrect.'</div>";
}
ob_flush();
?>
And lastly, here is contactfunctions.php
<?php ob_start();//Required for the redirect to work?>
<?php
include_once("databasefunctions.php");
$contactsdbtable = "contacts";
function GetHeaders()
{
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= "To: {$firstname} <{$email}>" . "\r\n";
$headers .= 'From: My Website <info#mywebsite.com>' . "\r\n";
return $headers;
}
function ContactMessage($firstname, $lastname, $email, $message, $location)
{
global $contactsdbtable;
openDatabase();
$firstname = mysql_real_escape_string($firstname);
$lastname = mysql_real_escape_string($lastname);
$email = mysql_real_escape_string($email);
$message = mysql_real_escape_string($message);
$location = mysql_real_escape_string($location);
$result = QuickQuery("INSERT INTO {$contactsdbtable}(firstname, lastname, email, message, location)
VALUES('{$firstname}', '{$lastname}', '{$email}', '{$message}', '{$location}')");
if($result)
{
$headers = GetHeaders();
$message = "\"Thank you for contacting us at My Website. We will be answering your website inquiry post haste.\"<br />
<br />
<br />
Best Regards,<br />
<br />
Me
";
mail($email, "RE: Design Inquiry", $message, $headers);
mail("myemail#blahblah.com", "Website Inquiry", "{$firstname}, {$email}, has sent a web design inquiry", $headers);
}
}
?>
I appreciate any help I receive on this in advance. Also, since this is a lengthy post, would you guys mind listing which issue you are addressing, 1 or 2?
Thanks!
Ok try this:
<?php
$is_error = false;
if($_POST['submitted'] == "contactus")
{
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$message = $_POST['message'];
$location = $_POST['location'];
if(!$firstname || $firstname = ''){
$error = "Please enter your first name.";
$is_error = true;
} else if(!$lastname || $lastname= ''){
$error = "Please enter your last name.";
$is_error = true;
} else if(!$email || $email= ''){
$error = "Please enter a valid email.";
$is_error = true;
}else if(!$message || $message= ''){
$error = "Please enter your message.";
$is_error = true;
}else if(!$location || $location= ''){
$error = "Please tell us where you're from.";
$is_error = true;
}
if(($is_error === false) && ($_SESSION['security_code'] == $_POST['security_code']))
{
ContactMessage($firstname, $lastname, $email, $message, $location);
} else {
Error($error);
}
}
?>

Categories