rondog Posted December 5, 2007 Share Posted December 5, 2007 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. Quote Link to comment Share on other sites More sharing options...
revraz Posted December 5, 2007 Share Posted December 5, 2007 According to this line $done = true; if($done == true) $done will always be true when this page loads. Quote Link to comment Share on other sites More sharing options...
fanfavorite Posted December 5, 2007 Share Posted December 5, 2007 Well the reason you are getting message of Error is because accountwasyes and accountwasno are only assigned when there are wrong answers ($wrongAnswers != ""). So it falls under the else. Not sure if you are asking anything else or not. Quote Link to comment Share on other sites More sharing options...
rondog Posted December 5, 2007 Author Share Posted December 5, 2007 dude yea I noticed this right after I posted..I have no idea why I put it there in the first place..sorry for wastin your guys time Quote Link to comment Share on other sites More sharing options...
revraz Posted December 5, 2007 Share Posted December 5, 2007 No worries, it's why the forums are here. I miss easy things in my code too, sometimes it just takes another pair of eyes. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.