PHP die()
(PS: I realize this script has holes I'm trying to get everything in order this is moreless a work in progress but suggestions welcome..for instance I know were in need of protecting against injection)
<?php
$uname="";
$pass="";
$db="";
mysql_connect("localhost",$uname,$pass);
@mysql_select_db($db) or die( "Unable to select database");
$fname=$_POST['first_name'];
$lname=$_POST['last_name'];
$email=$_POST['email'];
$pass=$fname.$lname;
$uname=$email;
$score=$_POST['scores'];
$query="INSERT INTO `anxiety_questions`.`user details` (`userid`, `password`, `first name`, `last name`, `email`,`score`) VALUES ('$uname', '$pass', '$fname', '$lname', '$email','$scores');";
$result=mysql_query($query);
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_from ="";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_to = $_POST['email'];
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_to)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
if($_POST['scores']<10){
echo "<tr>
<td align='center' valign='top' bgcolor='#838383' style='background-color:#838383;'><br>
<br>
<table width='600' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td align='left' valign='top' style='border-bottom:none;'><img src='http://www.MYSITE.ws/images/top.png' width='600' height='177' style='display:block; padding-left:0px; padding-bottom:0px; width:100%;'></td>
</tr>
<tr>
<td align='left' valign='top' bgcolor='#d3be6c' style='background-color:#d3be6c; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#000000; padding:0px 15px 10px 15px; border-top:none; border-bottom:none;'>
<div><img src='http://www.MYSITE.ws/images/divider.png' width='517' height='1'></div>
<div style='font-size:32px; color:#0066CC;'><b>$first_name, Your Test Results!</b></div>
<div><img src='http://www.MYSITE.ws/images/divider.png' width='517' height='10'></div>
<div style='font-size:32px; color:#555100;'></div>
<div><br>
<p align='left'>Thank you for taking the anxiety test on our site <a href='http://www.MYSITE.ws'>www.MYSITE.ws</a>
recently. Your results are very <strong>positive</strong>. It seems that right now you are free from anxiety and worries. That is fantastic news and you should be proud of yourself.<br>
<br>
<center>
<h2>Your Test Score is ".$_POST['scores']."</h2>
</center>
</p>
<p align='left'>However, as with most people, there has probably been a time in your life where you have felt anxious. It may have been something to do with work, your home life, money worries (like all of us) or something else. <br>
<br>
<p align='left'>We all know that Prevention is much better than trying to cure something once you have it. learning how to monitor stress levels and coping with everyday life is something you can do quite easily with a little help.<br></p>
<br>
<p align='left'>I have learnt this the hard way and I can now proudly say that I cope with stress and anxiety, mainly because of a great product called "Panic Away."</p>
<p align='left'><br>
This product is so good that I am offering a great deal for all my readers so you will never have to worry about facing anxious times on your own again.</p>
<p>
<center>
<h3> Grab your copy of panic away right now<br>
www.promosite.com
</h3>
<p><a href='http://www.PROMOSITE.com'><img border='0' src='http://www.MYSITE.ws/images/panic_away_banner.jpg'></a></p>
</center>
</p>
<p align='left'>We are updating our blog weekly so be sure to check back in often and learn everything you can, knowledge is key.</p><br>Thanks;<br>Desjardins, Jeff<br>
<br>
<br>
<br>
<br>
<b>
<center>
www.MYSITE.ws
</center>
</b><br>
</div></td>
</tr>
<tr>
<td align='left' valign='top' style='border-top:none;'><img src='http://www.MYSITE.ws/images/bot.png' width='600' height='18' style='display:block; padding-left:0px; padding-top:0px; width:100%;'></td>
</tr>
</table>
<br>
<br></td>
</tr>
</table> ";
}
else if(($_POST['scores']>11)&&($_POST['scores']<45)){
echo "<tr>
<td align='center' valign='top' bgcolor='#838383' style='background-color:#838383;'><br>
<br>
<table width='600' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td align='left' valign='top' style='border-bottom:none;'><img src='http://www.MYSITE.ws/images/top.png' width='600' height='177' style='display:block; padding-left:0px; padding-bottom:0px; width:100%;'></td>
</tr>
<tr>
<td align='left' valign='top' bgcolor='#d3be6c' style='background-color:#d3be6c; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#000000; padding:0px 15px 10px 15px; border-top:none; border-bottom:none;'>
<div><img src='http://www.MYSITE.ws/images/divider.png' width='517' height='1'></div>
<div style='font-size:32px; color:#0066CC;'><b>$first_name, Your Test Results!</b></div>
<div><img src='http://www.MYSITE.ws/images/divider.png' width='517' height='10'></div>
<div style='font-size:32px; color:#555100;'></div>
<div><br>
<p align='left'>Thank you for taking the anxiety test on our site <a href='http://www.MYSITE.ws'>www.MYSITE.ws</a> recently. According to your answers, it seems that you're suffering from a <b>mild level</b> of anxiety at the moment and you should take some precautions to ensure it doesn't get worse.<br>
<br>
<center>
<h2>Your Test Score is ".$_POST['scores']."</h2>
</center>
</p>
<p align='left'>If you're the sort of person who prefers medication and support from your doctor, that's fine and it may help you.<br>
<br>
<p align='left'>However, if you're like me and would rather be your own doctor, learn more about your health and how to improve it yourself, then I highly recommend a product that will help you do just that.<br></p>
<br>
<p align='left'>I have learnt this the hard way and I can now proudly say that I cope with stress and anxiety, mainly because of a great product called "Panic Away."</p>
<p align='left'><br>
This product is so good that I am offering a great deal for all my readers so you will never have to worry about facing anxious times on your own again.</p>
<p>
<center>
<h3> Grab your copy of panic away right now<br>
www.PROMOSITE.com
</h3>
<p><a href='http://www.PROMOSITE.com'><img border='0' src='http://www.MYSITE.ws/images/panic_away_banner.jpg'></a></p>
</center>
</p>
<p align='left'>We are updating our blog weekly so be sure to check back in often and learn everything you can, knowledge is key.</p><br>Thanks;<br>Desjardins, Jeff<br>
<br>
<br>
<br>
<br>
<b>
<center>
www.MYSITE.ws
</center>
</b><br>
</div></td>
</tr>
<tr>
<td align='left' valign='top' style='border-top:none;'><img src='http://www.MYSITE.ws/images/bot.png' width='600' height='18' style='display:block; padding-left:0px; padding-top:0px; width:100%;'></td>
</tr>
</table>
<br>
<br></td>
</tr>
</table> ";
}
else if(($_POST['scores']>45)&&($_POST['scores']<88)){
echo "<tr>
<td align='center' valign='top' bgcolor='#838383' style='background-color:#838383;'><br>
<br>
<table width='600' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td align='left' valign='top' style='border-bottom:none;'><img src='http://www.MYSITE.ws/images/top.png' width='600' height='177' style='display:block; padding-left:0px; padding-bottom:0px; width:100%;'></td>
</tr>
<tr>
<td align='left' valign='top' bgcolor='#d3be6c' style='background-color:#d3be6c; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#000000; padding:0px 15px 10px 15px; border-top:none; border-bottom:none;'>
<div><img src='http://www.MYSITE.ws/images/divider.png' width='517' height='1'></div>
<div style='font-size:32px; color:#0066CC;'><b>$first_name, Your Test Results!</b></div>
<div><img src='http://www.MYSITE.ws/images/divider.png' width='517' height='10'></div>
<div style='font-size:32px; color:#555100;'></div>
<div><br>
<p align='left'>Thank you for taking the anxiety test on our site <a href='http://www.MYSITE.ws'>www.MYSITE.ws</a> recently. According to your answers, it seems that you're suffering from a <b>severe level</b> of anxiety at the moment. This means that you should seek immediate treatment to prevent it from getting any worse.<br>
<br>
<center>
<h2>Your Test Score is ".$_POST['scores']."</h2>
</center>
</p>
<p align='left'>You have several options. You can speak to your doctor and have him/her prescribe medication that you may/may not have taken before. Often that is all it takes to bring your stress levels back down to a normal level.<br>
<br>
<p align='left'>But your test results show that the problem is possibly deeper than that and it may be wise to try another approach as well.<br></p>
<br>
<p align='left'>I know exactly how you feel because I have suffered from severe anxiety levels in the past but I found a solution that has empowered me to take back control of my life. It's a product called "Panic Away." </p>
<p align='left'><br>
This product is so good that I am offering a great deal for all my readers so you will never have to worry about facing anxious times on your own again.</p>
<p>
<center>
<h3> Grab your copy of panic away right now<br>
www.PROMOSITE.com
</h3>
<p><a href='http://www.PROMOSITE.com'><img border='0' src='http://www.MYSITE.ws/images/panic_away_banner.jpg'></a></p>
</center>
</p>
<p align='left'>We are updating our blog weekly so be sure to check back in often and learn everything you can, knowledge is key.</p><br>Thanks;<br>Desjardins, Jeff<br>
<br>
<br>
<br>
<br>
<b>
<center>
www.MYSITE.ws
</center>
</b><br>
</div></td>
</tr>
<tr>
<td align='left' valign='top' style='border-top:none;'><img src='http://www.MYSITE.ws/images/bot.png' width='600' height='18' style='display:block; padding-left:0px; padding-top:0px; width:100%;'></td>
</tr>
</table>
<br>
<br></td>
</tr>
</table> ";
}
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
$headers .= "CC: susan@example.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
Click <a href="index.php"> here </a>to Take the test again
<style type="text/css">
#header { margin-top:0px; }
.content table tr td { padding: 0px 0px 0px 0px; }
</style>
<?php
}
?> -
KirkMcD -
Thanks
{{ DiscussionBoard.errors[5809906].message }} -
-
solidsoul -
Thanks
SignatureCanadian Installment Loan Affiliate Program | High Conversions{{ DiscussionBoard.errors[5810050].message }} -
-
Earnie Boyd -
Thanks
SignatureEarnie Boyd{{ DiscussionBoard.errors[5810393].message }} -
-
solidsoul -
Thanks
SignatureCanadian Installment Loan Affiliate Program | High Conversions{{ DiscussionBoard.errors[5810913].message }} -
-
Earnie Boyd -
Thanks
SignatureEarnie Boyd{{ DiscussionBoard.errors[5811043].message }} -