Jump to content

[SOLVED] need help with php logic


rondog

Recommended Posts

Ok my script is somewhat working. I've made a quiz in flash and every time you enter a wrong answer, it stores it in an array. If I submit the data once everything is answered correctly, it echoes "success". If I answer everything correctly first time around meaning the wrong answer array is empty, it echoes "error"

 

Can anyone see what I am doing wrong?

<?php
include 'connect.php';
$done = false;
$title = $_POST['theTitle'];
$name = $_POST['theName'];
$account = $_POST['theCurAct'];
$subtitle = $_POST['theSubTitle'];
$address1 = $_POST['theAdd1'];
$address2 = $_POST['theAdd2'];
$city = $_POST['theCity'];
$state = $_POST['theState'];
$zip = $_POST['theZip'];
$phone = $_POST['thePhone'];
$email = $_POST['theEmail'];
$testNum = $_POST['theTestNumber'];
//wrong answer array
$wrongAnswers = $_POST['wrongs'];
$wrongAnswers_arr = explode(",",$wrongAnswers);
$done = true;
if($done == true) {
if($account == 'no') {
	$sql1 = mysql_query("INSERT INTO users (title,name,subtitle,address1,address2,city,state,zip,phone,email) VALUES ('$title','$name','$subtitle','$address1','$address2','$city','$state','$zip','$phone','$email')");
	if($wrongAnswers != "") {
		foreach($wrongAnswers_arr as $wa) {
			$accountWasNo = true;
			$sql2 = mysql_query("INSERT INTO tests (testNum,testQuestion) VALUES ('$testNum','$wa')");
		}
	}
} else {
	if($wrongAnswers != "") {
		foreach($wrongAnswers_arr as $wa) {
			$accountWasYes = true;
			$sql2 = mysql_query("INSERT INTO tests (testNum,testQuestion) VALUES ('$testNum','$wa')");
		}
	}
}
if($accountWasNo == true) {
	echo "&msgText=Success";
	$headers = "From: some@email.com\r\n";
	$headers.= "Content-Type: text/html; charset=ISO-8859-1 ";
	$headers .= "MIME-Version: 1.0 ";
	$msg = "Hello $firstName $lastName,<br/>";
	$msg .= "We would like to thank you for joining our web site.<br/>";
	$msg .= "Please enjoy it and if you have any questions, contact us at <a href=\"mailto:admin@flashsite.com\">admin@flashsite.com</a>.";
	mail($email,"**SynergEyes Practice Prescribe It! Certification**",$msg,$headers);
} elseif($accountWasYes == true) {
	echo "&msgText=Success";
} else {
	echo "&msgText=Error";
}
}
?>

 

just a little info, account = yes will insert the users data and account = no will not enter their information, just the answers they got wrong..if they got any wrong.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.