PHP - Php Script Randomly Restarts Itself With Blank Post Data
I've managed to isolate a problem I'm having with my php script. It would seem the script randomly restarts itself with blank post data while it's running.
I've managed to mimick the problem using a very basic php script which just pauses and writes to a log: <?php $q = $_POST['q']; if ($q==""){ writelog ("MISFIRE!!!"); die; } writelog("\n*** Error check started ***"); for ($i = 1; $i <= 50; $i++) { writelog ($i); sleep(rand(2,20)); } function writelog($towrite) { $tdate=date('d/m/Y H:i:s'); $file = 'log/testlog.txt'; $current = $towrite." --- ".$tdate."\n"; file_put_contents($file, $current, FILE_APPEND); } writelog("*** Error check ended ***"); ?>To rule out any problems with my AJAX htmlhttp requests, I simply send the script some irrelevant post data using Chrome's Advanced Restful client. This is the ouput of the log from an example test run: *** Error check started *** --- 05/06/2014 18:27:30 1 --- 05/06/2014 18:27:30 2 --- 05/06/2014 18:27:44 3 --- 05/06/2014 18:27:49 4 --- 05/06/2014 18:27:59 5 --- 05/06/2014 18:28:04 6 --- 05/06/2014 18:28:22 7 --- 05/06/2014 18:28:33 8 --- 05/06/2014 18:28:39 9 --- 05/06/2014 18:28:52 10 --- 05/06/2014 18:29:08 11 --- 05/06/2014 18:29:22 12 --- 05/06/2014 18:29:30 13 --- 05/06/2014 18:29:43 MISFIRE!!! --- 05/06/2014 18:29:46 14 --- 05/06/2014 18:29:56 15 --- 05/06/2014 18:30:07 16 --- 05/06/2014 18:30:09 17 --- 05/06/2014 18:30:15 18 --- 05/06/2014 18:30:32 19 --- 05/06/2014 18:30:52 20 --- 05/06/2014 18:30:54Note the logged "Misfire" after the 13th entry. This shows the script tried to run again with blank post data, the same problem I'm having in my more complex script. Why could this be happening? It's not anyone else calling the script, nobody knows about the site and I've ruled it out by logging the IP in my real script. Edited by holdorfold, 05 June 2014 - 02:29 PM. Similar Tutorialsok..ive done this a million times..i have a working example here and i copied it and amended it for this new project but for some reason i cant get a form to post data to another page. this is the error message i get Notice: Undefined index: username in C:\wamp\www\uni\fyp\site\mobile\login.php on line 16 Notice: Undefined index: password in C:\wamp\www\uni\fyp\site\mobile\login.php on line 17 here is my form code: <form method="post" action="login.php"> <table align="center" cellpadding="0" cellspacing="0"> <tr> <td style="vertical-align:top;">Username: </td><td><input type="text" name="username" value="" /></td> </tr> <tr> <td style="vertical-align:top;">Password: </td><td><input type="password" name="password" value="" /><br /><input type="submit" id="submit" value="Login" /></td> </tr> </table> </form> and here is the code within the login.php where the form should post to $username = $_POST['username']; $password = $_POST['password']; // Help protect against MySQL injection $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); // Selecting data from database where correct username and password are found $sql="SELECT * FROM customer WHERE username='$username' and password='$password'"; $result=mysql_query($sql) or die(mysql_error()); i cant see anything wrong..been looking for hours...please please help me Hi all, Thanks for reading. I'm hella frustrated at this script I wrote: for some reason, it will not work correctly. Basically, it works. The first 4 names in the table on the database show up when searched. But, anything past these four names in the database will not show up as a result when searched! I'm pulling my hair out here! It's really simple - take a gander: Code: [Select] if (isset($_POST['submit'])) { $search = $_POST['search']; $searchQuery = mysql_query("SELECT * FROM Accounts WHERE FullName='$search'"); if (mysql_num_rows($searchQuery) == 0) { $result = "Your search returned no results. Please try again."; } else { $results = 1; while ($getSearchResults = mysql_fetch_array($searchQuery)) { $fullName = $getSearchResults['FullName']; $result = "Name: ".$fullName.""; } } } ?> ...and the HTML form... Code: [Select] <form action="search.php" method="post"> <p>Search: <input type="text" name="search" size="35" maxlength="100" /></p> <p><input type="submit" value="Search" name="submit" /></p> <?php echo $result; ?> </form> Does anyone have any ideas? Good morning, I am a beginner at PHP, but trying to write a simple script to use at work and currently stuck on one part, looking for some advice! I have a simple form here > http://jmdostal.com/route2.php (Feel free to use it to test), that returns data on the next page, in a format such as : Jose F - Jose A - 285 Brenda L [Delivery] [Dallas] - Items Job 2 [Pickup] [Arlington] - Items [] [] - [] [] - [] [] - [] [] - [] [] - Gustavo - +1 - 284/pickup Jody W [Delivery] [Keller] - Items [] [] - [] [] - [] [] - [] [] - [] [] - [] [] - My question is how can I get it not to show the fields that are empty, so I dont have a bunch of lines with [] [] - formatting Here is my coding you can view here > http://jmdostal.com/code.txt A friend had suggested to me trying to use isset , so I tried it on a few lines, such as : if(isset($_POST['items14'])){ $items14 = "- ". Trim(stripslashes($_POST['items14'])); } But it didnt seem to change anything. Im sure this is something simply, Any suggestions are appreciated! Thanks ! $post='{"cart_items":[{"configuration":{"price":100,"recharge_number":"9999999999"},"product_id":"999","qty":1}]}';i try this n reslut was :There are no valid items in cart: help me plz Edited by ShivaGupta, 30 November 2014 - 01:11 AM. Hi, I created the login page below. However, when I enter details on the form I am getting a blank page. I can't figure out what is wrong. Any help/suggestions really welcome. Thanks in advance. Code: [Select] <html> <html lang="en"> <head> <meta charset="utf-8" /> <title>LOGIN FUNCTION</title> </head> <body> <?php require('connection.php'); if(empty($_POST['name'])){ $name=NULL; echo "Sorry, you forgot to enter your username.</br>"; }else{ $name=@mysqli_real_escape_string($connection, trim($_POST['name'])); } if(empty($_POST['password'])){ $password=NULL; echo "Sorry, you forgot to enter a password.</br>"; }else{ $password=@mysqli_real_escape_string($connection, trim($_POST['password'])); } if(($name) && ($password)){ $info = "SELECT * FROM users WHERE username=$name and password=$password"; $return=@mysqli_query($connection, $info); $count_rows=@mysqli_num_rows($return); if($count_rows==1){ session_start(); if(isset($_SESSION['login'])){ header("Location:admin.php"); }else{ header("Location:login_fail.php"); } } } ?> Hi guys! New to the community and hope to learn a lot here! Here is some background info and what I want to do, and what I know. I have been building websites for years, and I am familiar with Actionscript 3.0. And I have successful ran a few wordpress websites. What I am trying to do right now however is modify this form script I found, to only email the data when the field isn't left blank. It's stumping me because the actual "message" that ends up being the body of the email is a variable. And form what I can tell I can't figure out how to put if statements into it. If anyone can take a look at this script and give me any pointers you would be awesome. Code: [Select] <?php //trying to store the date in a separate variable only when it's not blank if ($_POST['starttime'] == '') { //nothing; } else { $showStartTime == "Start time: " . $_POST['starttime'] . ""; } if ($_POST['finishtime'] == '') { //nothing; } else { $showFinishTime == "Finish time: " . $_POST['finishtime'] . ""; } // Read POST request params into global vars $to = $_POST['to']; $from = $_POST['from']; $name = $_POST['name']; $company = $_POST['company']; $newcustomer = $_POST['newcustomer']; $address1 = $_POST['address1']; $address2 = $_POST['address2']; $subject = ("Event Rental for " . $name . ""); $description = $_POST['description']; $phone = $_POST['phone']; $message = (" Name: " . $name . " Company or Organization: " . $company . " Phone Number: " . $phone . " Email Address: " . $from . " Street Address: " . $address1 . " " . $address2 . " New Customer: " . $newcustomer . " Customer From: " . $_POST['howyouheard'] . " Interested in: SkyLoft " . $_POST['whichspace'] . " Date: " . $_POST['date'] . " Day of Week: " . $_POST['dayofweek'] . " " . $showStartTime . " " . $showFinishTime . " Number of Guests: " . $_POST['Guests'] . " Format: " . $_POST['format'] . " Occasion: " . $_POST['Occasion'] . " Optional Needs: " . $_POST['dj'] . " " . $_POST['tables'] . " " . $_POST['chairs'] . " " . $_POST['eventbanner'] . " " . $_POST['pasoundsystem'] . " Message: " . $description . " "); // Obtain file upload vars $fileatt = $_FILES['fileatt']['tmp_name']; $fileatt_type = $_FILES['fileatt']['type']; $fileatt_name = $_FILES['fileatt']['name']; $headers = "From: $from"; if (is_uploaded_file($fileatt)) { // Read the file to be attached ('rb' = read binary) $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); // Generate a boundary string $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // Add the headers for a file attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // Add a multipart boundary above the plain message $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; // Base64 encode the file data $data = chunk_split(base64_encode($data)); // Add file attachment to the message $message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; } // Send the message $ok = @mail($to, $subject, $message, $headers); if ($ok) { echo "<p><b>Thank you for your interest in SkyLofts!</b> <br>You should recieve a verification in your inbox that we recieved your request. We will contact you as soon as possible and hopefully be able to answer any questions you may have! You can also contact us via phone 410-791-6699, or toll-free 1-800-344-0410.</p>"; } else { echo "<p>There was an error when processing your request. Please try again.</p>"; } ?> hi all i am having a big problem that i have been trying to find out what is going on for weeks. i have a echo script that echos data that is in my database, and if i have to refresh the page it will add blank data in my database and the top echo info is blank as well. how can i fix this, and i was wanting to know how do i echo out my info in a textarea. i added a jepg to show you what i mean. here is my code echoforms.php <?php error_reporting(0); require_once('demo.php'); /*Open the connection to our database use the info from the config file.*/ $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); $sql = "SELECT company_name, contact_name, address, street_number, postcode, contact_number, contact_email, budget, description FROM 3dartactforms"; $results = mysql_query($sql); if (!$results) { die('Invalid query: ' . mysql_error()); } while($result = mysql_fetch_array( $results )){ echo '<div style="border: 1px solid #e4e4e4; padding: 15px; margin-bottom: 10px;">'; echo date("d/m/y"); echo '<p>Company Name: ' . $_POST['company_name'] . '</p>'; echo '<p>Contact Name: ' . $_POST['contact_name'] . '</p>'; echo '<p>Address: ' . $_POST['address'] . '</p>'; echo '<p>Street Number: ' . $_POST['street_number'] . '</p>'; echo '<p>Postcode: ' . $_POST['postcode'] . '</p>'; echo '<p>Contact Number: ' . $_POST['contact_number'] . '</p>'; echo '<p>Contact Email: ' . $_POST['contact_email'] . '</p>'; echo '<p>Budget: ' . $_POST['budget'] . '</p>'; echo '<p>Description: ' . $_POST['description'] . '</p>'; echo '</div>'; } ?> This topic has been moved to Editor Help (Dreamweaver, Zend, etc). http://www.phpfreaks.com/forums/index.php?topic=349934.0 Login.php Code: [Select] <?php session_start(); mysql_connect("localhost","root") or die(mysql_error()); mysql_select_db("cute") or die(mysql_error()); $username = $_POST['username']; $password = $_POST['pass']; if (isset($_POST["submit"])) { $log = "SELECT * FROM regis WHERE username = '$username'"; $login = mysql_query($log); $row = mysql_fetch_array($login); $number = mysql_num_rows($login); if ($number == 0) { print "That user does not exist in our database. <a href=registration.php><input type='button' value='Register'></a>"; } if ($number > 0) { if ($password == $row['password']) { $_SESSION['username'] = $row['username']; $_SESSION['userlevel'] = $row['userlevel']; $_SESSION['is_logged_in'] == 1; if($_SESSION['userlevel']==1) { $_SESSION['is_logged_in'] == 1; echo "<meta http-equiv='refresh' content='0; url=form2.php'>" ; } else if($_SESSION['userlevel']==0) { echo "<meta http-equiv='refresh' content='0; url=registration.php'>"; } } } } else { ?> <html> <head> <script type="text/javascript"> function a() { var x = document.login.username.value; var y = document.login.pass.value; if(x==""&& y=="") { alert("Please insert all message!"); return false; } if(x=="") { alert("Please insert an username!"); return false; } if(y=="") { alert("Please insert an password!"); return false; } } </script> </head> <body> <table border="0"> <form name="login" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" onsubmit="return a()"> <tr><td colspan=2><h1>Login</h1></td></tr> <tr><td>Username:</td> <td><input type="text" name="username" maxlength="40"></td></tr> <tr><td>Password:</td> <td><input type="password" name="pass" maxlength="50"></td></tr> <tr><td><input type="submit" name="submit" value="Register"></a></td> <td><input type="submit" name="submit" value="Login"></td></tr> </form> </body> <?php } ?> </html> after im redo my code and after im login there nothign happen but only blank page im wondering why Hi there, I am using this code to send the users email address to the database. That works fine, but i keep getting blank info added to the database. Does anyone know how i can stop this? <?php $con = mysql_connect("*","*","*"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ogs_mailinglist1", $con); $sql="INSERT INTO mailinglist (email) VALUES ('$_POST[rec_email]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con); ?> Thanks, Hi guy's, I'm having problems adjusting a script to add a level (user rights) function. When i login with a admin or normal user it gives a blank page (not redirecting to home.php). It even does'nt return an echo that user / pass is incorrect. I'm breaking my head over this for day's now. Can you help me out? Code: [Select] <?php session_start(); //Login form (index.php) include "db_connect.php"; if(!$_POST['submit']) { ?> <html> <head> <!--[if IE]> <link rel="stylesheet" type="text/css" href="style.css" /> <![endif]--> <![if !IE]> <link rel="stylesheet" type="text/css" href="firefox.css" /> <![endif]> </head> <body> <div id="wrapper"> <div id="header"> <?php include('header.php'); ?> </div> <div class="divider"> <strong>Login</strong> <form method="post" action="index.php"> <div class="formElm"> <label for="username">Klantnummer:</label> <input id="username" type="text" name="username" maxlength="16"> </div> <div class="formElm"> <label for="password">Wachtwoord:</label> <input type="password" name="password" maxlength="16"> </div> <input type="submit" name="submit" value="Login"> </form> </div> <div id="footer"> <?php include('footer.php'); ?> </div> </div> </html> <?php } else { $user = protect($_POST['username']); $pass = protect($_POST['password']); $level = protect($_POST['level']); if($user && $pass && $level) { $pass = md5($pass); //compare the encrypted password $sql1 ="SELECT id,username FROM `users` WHERE `username`='$user' AND `password`='$pass' AND `level`='1'"; $sql2 ="SELECT id,username FROM `users` WHERE `username`='$user' AND `password`='$pass' AND `level`='9'"; $queryN=mysql_query($sql1) or die(mysql_error()); $queryA=mysql_query($sql2) or die(mysql_error()); if(mysql_num_rows($queryN) == 1) { $resultN = mysql_fetch_assoc($queryN); $_SESSION['id'] = $resultN['id']; $_SESSION['username'] = $resultN['username']; header("location:home.php"); } elseif(mysql_num_rows($queryA) == 1) { $resultA = mysql_fetch_assoc($queryA); $_SESSION['id'] = $resultA['id']; $_SESSION['username'] = $resultA['username']; header("location:home.php"); } else{ echo "Wrong Username or Password"; } } } ?> and the mysql code: Code: [Select] CREATE TABLE `user` ( `id` int(4) unsigned NOT NULL auto_increment, `username` varchar(32) NOT NULL, `password` varchar(32) NOT NULL, `level` int(4) default '1', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=latin1; Hi guys, I think I may be losing my marbles over this form I've put together. I'm trying to get my code to post the following to a database but my MySQL and PHP isn't that good, so wondering if any one could possibly suggest what I could do? Here is my code: Code: [Select] <?php // we check if everything is filled in if(empty($_POST['fname']) || empty($_POST['lname']) || empty($_POST['email'])) { die(msg(0,"All the fields are required")); } // is the sex selected? if(!(int)$_POST['sex-select']) { die(msg(0,"You have to select your sex")); } // is the birthday selected? if(!(int)$_POST['day'] || !(int)$_POST['month'] || !(int)$_POST['year']) { die(msg(0,"You have to fill in your birthday")); } // is the email valid? if(!(preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $_POST['email']))) die(msg(0,"You haven't provided a valid email")); // I think here is where I need to put something to get the data into a table! echo msg(1,"registered.html"); function msg($status,$txt) { return '{"status":'.$status.',"txt":"'.$txt.'"}'; } ?> How do I get the $_POST['day'] and $_POST['month'], $_POST['year'] etc into a table? It should be so easy but my head is hurting from trying lots of things and tutorials online. Any thoughts my PHP Freaks? im trying to understand this Post Data script it's not posting, no errors: postdata.php Code: [Select] <?php //create array of data to be posted //$post_data['firstName'] = 'Name'; $post_data['item_name'] = '12345'; //traverse array and prepare data for posting (key1=value1) foreach ( $post_data as $key => $value) { $post_items[] = $key . '=' . $value; } //create the final string to be posted using implode() $post_string = implode ('&', $post_items); //we also need to add a question mark at the beginning of the string $post_string = '?' . $post_string; //we are going to need the length of the data string $data_length = strlen($post_string); //let's open the connection $connection = fsockopen('www.example.com', 80); //sending the data fputs($connection, "POST /i.php HTTP/1.1\r\n"); fputs($connection, "Host: www.example.com \r\n"); fputs($connection, "Content-Type: application/x-www-form-urlencoded\r\n"); fputs($connection, "Content-Length: $data_length\r\n"); fputs($connection, "Connection: close\r\n\r\n"); fputs($connection, $post_string); //closing the connection fclose($connection); ?> reuslt should be posted here i.php Code: [Select] <?php require('database_connection.php');?> <?php if(isset($post_items[0])) { //$Subscription_id = mysql_real_escape_string($md5c); //$PropertyID = mysql_real_escape_string($rowData['ID']); //$User_ID = mysql_real_escape_string($rowData['User_ID']); $item_name=mysql_real_escape_string($post_items[0]); $query = 'INSERT INTO SP_subscriptions(id,) values("'.$item_name.'")'; //$query = 'INSERT INTO SP_subscriptions(id,PropertyID,User_ID) values("'.$item_name.'","'.$PropertyID.'","'.$User_ID.'")'; $success = mysql_query($query); } else { $item_name=54321; $query = 'INSERT INTO SP_subscriptions(id) values('.$item_name.')'; //$query = 'INSERT INTO SP_subscriptions(id,PropertyID,User_ID) values("'.$item_name.'","'.$PropertyID.'","'.$User_ID.'")'; $success = mysql_query($query);} //var_dump($_POST); //var_dump($query); echo $query; ?> Hi I have a little strange problem. I cannot get the post data from my form. It works fine if there is 10 or 15 user but reaching 40 or more than form values not posting. This is output of size: echo (int) $_SERVER['CONTENT_LENGTH']; ===== 22164 Code: [Select] if(isset($_POST['hiddenField'])) { // do some work; } $sql = mysql_query("SELECT id, name FROM user WHERE shop_id = '" .$_SESSION['id']. "' ORDER BY name ASC"); while($row = mysql_fetch_array($sql)) { echo ' <div style="width:100%; border:solid 1px #CCC; background-color:#f1e7e7; margin-bottom:5px;"> <table class="tableSmall"> <tr><th width="81">' .$row['name']. '</th><th width="71">'; echo $grl_pic .' </th> <td width="622"><table width="100%"> <tr>'; for($j=0; $j<7; $j++) { $sql2 = mysql_query("SELECT user_master_id, user_start, user_end FROM work_master WHERE user_master_id = '" .$row['id']. "' AND date = '" .$days_no_kanji[$j]. "'"); $row2 = mysql_fetch_array($sql2); if(mysql_num_rows($sql2) == 0) { $start = "00:00"; $end = "00:00"; $m = 0; } else { $start = $row2['user_start']; $end = $row2['user_end']; $m = 1; } echo ' <th><input type="hidden" name="userData[]" value="' .$row['id']. '_' .$j .'_' .$m. '" /> <select name="' .$row['id']. '_' .$j .'_' .$m. '_start">' .ShopHour($start). '</select><br />~<br /> <select name="' .$row['id']. '_' .$j .'_' .$m. '_end">' .ShopHour($end). '</select> </th>'; } echo ' </tr> </table></td> </tr> </table> </div>'; } Is there someone has any idea why php is not posting? Hello, I need to post plenty of data to a file with a java file with a .do extension using a php program. How do I get to auto-post mass data in php from a database straight to this java file? Put in mind that each mysql record is posted as its own form as in: <form ...>mysql record</form> Thanks in advance Hi All, Not sure if this is a silly question so here we go. I have some divs that have data attributes (data-value). When i submit and post the form, can i use these values as part of the submission and put their data-value into the db? Thanks as always in advance. Hello
I have a nusoap web service running, which is fine, but I need to send a new variable in the parameters which decides what database to use...
This is how I call the function:
$params = array( 'region' => '1' ); $response1 = $client->call('function1', array ($params)); // response will be in JSON I'm doing an ajax call from javascript using jquery library: Code: [Select] ajaxCall: function(process, obj, type){ $.post("registration-post.php", type + "=" + process, function(data){ if(data==""){ $(obj).css(registration.errorNotificationType, registration.validatedColour); }else{ $('.error').append($.trim(data) + "<br />"); $(obj).css(registration.errorNotificationType, registration.errorColour); registration.progress = false; } } ); } When the ajax calls the php page, I want the php page to know what post information the javascript has sent, rather than pre-defining what the PHP should be trying to retrive from the POST data. Something like // pseudo $_POST["whateverwassentfromajax"] I want to do this because I want to have one function doing everything. So in my javascript I am saying, check if the username and email have already been used... But i dont want to call two different php functions. //pseudo function 1(){ $_POST["username"]; } function 2(){ $_POST["email"]; } Is there a special way to know which post data has been sent. Or do i need to do a few if statements in php. i am trying to fit this php code to so when ever i upload a video link to the database it prints in the divs from left to right. ( i have made blank boxes for where the videos should be, so you guys can see what i mean. i will give you the code here. Code: [Select] <?php $query = mysql_query("SELECT * FROM `G4V_Videos` ORDER BY `id` DESC") or die(mysql_error()); while ($data = mysql_fetch_array($query)) { ?> ID-nummer: <?php print $data['id']; ?> - Name: <?php print $data['navn']; ?> - <a href="/Video.php?id=<?php print $data['id']; ?>"><img src="http://i.ytimg.com/vi/<?php print $data['link'];?>/hqdefault.jpg" width="200" height="160" /></a><br /> <a href="/Video.php?=<?php print $data['id']; ?>"> <?php } ?> and the website is here, http://www.game4vids.com/index.php and i also want it so once i have used up all the boxes it posts the new video in box one and overwrites the old one if you get what i mean. This website is a great example of what i mean. http://www.retardo.dk Hi guys, I am creating a quiz system for my personal site, I am done with all the quiz questions creating part, but I am stuck with something like... user taking a random sql generated quiz and submitting it.. Here's randomly generated sql quiz, even the answers are in random order: <form method="post"> <b>1. What is color or sky</b> <ol> <li><input name="question_3_answer" type="radio" value="6" /> sky</li> <li><input name="question_3_answer" type="radio" value="8" />blue</li> <-- true <li><input name="question_3_answer" type="radio" value="3" />red</li> </ol> <b>2. What is name of my cat</b> <ol> <li><input name="question_6_answer" type="radio" value="9" />brat</li> <--true <li><input name="question_6_answer" type="radio" value="7" />rat</li> </ol> <b>3. What is name of my pet</b> <ol> <li><input name="question_18_answer" type="radio" value="9" />cat</li> <--true <li><input name="question_18_answer" type="radio" value="7" />dog</li> </ol> </form> Now this is tricky part for me is.. receiving these data in another page.. since it's randomly generated questions, how do I know which question it is? here's example I've tried : $list_all_quiz_questions = $db->get_row("SELECT question_id, its_true_ans_id FROM question_table WHERE quiz_group = 'ef23fsdfers3e' "); $i = 1; foreach ($list_all_quiz_questions as $myquestion) { $answer.$i == $_POST["question_".$myquestion->question_id."_answer"]; //?????????? not working lol ;(( $i++ } |