Jump to content

MFA

Members
  • Posts

    32
  • Joined

  • Last visited

Everything posted by MFA

  1. did it and got "Array ( [questionsession] => Which of the following is a side effect of furesomide? [asession] => Sample answer A [bsession] => Sample answer B [csession] => Sample answer C [dsession] => Sample answer D [esession] => Sample answer D [answersession] => The answer is [insert explanation]. If you see this text, SYSTEM works. [correctsession] => B )" so it seems to work. mcq.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php session_start(); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php include 'dbyear2.php'; $qnumber = ($_REQUEST['uqn']); // obtain question number from URL $find = mysqli_query($condbyear2, "SELECT * FROM Renal WHERE UQN='$qnumber'"); $retrieve=mysqli_fetch_assoc($find); { $question = $retrieve['question']; $a = $retrieve['MCQ_A']; $b = $retrieve['MCQ_B']; $c = $retrieve['MCQ_C']; $d = $retrieve['MCQ_D']; $e = $retrieve['MCQ_E']; $answer = $retrieve['answer']; $correct = $retrieve['MCQ_correct']; } { $_SESSION['questionsession'] = $question; $_SESSION['asession'] = $a; $_SESSION['bsession'] = $b; $_SESSION['csession'] = $c; $_SESSION['dsession'] = $d; $_SESSION['esession'] = $e; $_SESSION['answersession'] = $answer; $_SESSION['correctsession'] = $correct; } ?> <form action='check.php' method='POST'> <table width="90%" border="0%" cellpadding="6" align="center"> <tr><td width="6%"></td><td width="94%"><?php echo $question; ?></td></tr> <tr></tr> <tr><td><input type='radio' name='group1' value='A' /></td><td> <?php echo $a; ?></td></tr> <tr><td><input type='radio' name='group1' value='B' /></td><td> <?php echo $b; ?></td></tr> <tr><td><input type='radio' name='group1' value='C' /></td><td> <?php echo $c; ?></td></tr> <tr><td><input type='radio' name='group1' value='D' /></td><td> <?php echo $d; ?></td></tr> <tr><td><input type='radio' name='group1' value='E' /></td><td> <?php echo $e; ?></td></tr> <tr></tr> <tr><td><input type="submit" value="Submit"></td></tr> </table> </form> </body> </html> check.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php session_start(); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php include 'dbyear2.php'; $question = $_SESSION['questionsession']; $a = $_SESSION['asession']; $b = $_SESSION['bsession']; $c = $_SESSION['csession']; $d = $_SESSION['dsession']; $e = $_SESSION['esession']; $answer = $_SESSION['answersession']; $correct = $_SESSION['correctsession']; // must insert table here again $choice = $_POST['group1']; echo $question; if (!isset($choice)) { echo "You did NOT select an answer. The correct choice was $correct"; } else if ($choice == $correct) { echo "Well done - You chose the correct answer $correct"; } else {echo "Incorrect answer! - The correct choice was $correct"; } echo "$answer"; // Copy the detailed answer here // end session? and destroy the set varaibles? - as this is 1MCQ answer mode not TEST mode. ?> </body> </html> yeah, true but i'm using the variables in my form so its quicker to type then session[''] each time. but i suppose it would be the same if i just did what you said cause i wouldnt have to waste time assigning variables. thank you.
  2. yes those variables work and are obtained from a mysqli_query. I used the {} just to group them together lol
  3. my variables from page 1 are not being sent to page 2 using sessions. i have tried to echo them and it is not working. when i use print_r for the sessions on page2.php, all i see is "array()" on my site. can someone please help. page1.php <?php session_start(); { $_SESSION['questionsession'] = $question; $_SESSION['asession'] = $a; $_SESSION['bsession'] = $b; $_SESSION['csession'] = $c; $_SESSION['dsession'] = $d; $_SESSION['esession'] = $e; $_SESSION['answersession'] = $answer; $_SESSION['correctsession'] = $correct; } ?> page2.php <?php session_start(); $question = $_SESSION['questionsession']; $a = $_SESSION['asession']; $b = $_SESSION['bsession']; $c = $_SESSION['csession']; $d = $_SESSION['dsession']; $e = $_SESSION['esession']; $answer = $_SESSION['answersession']; $correct = $_SESSION['correctsession']; echo $question; // NOT WORKING!! ?>
  4. It works now and I understood your explanation. Thank you. I will look into the debugging methods you suggested for next time however like I said I'm very new.
  5. my code doesnt seem to work.. the radio buttons appear but nothing beside them .. what i know already: mysql_fetch_row is working - i have tested this using mysqli_num_rows() mysqli_query is working - testing in phpmyadmin and also proven above the problem seems to be with $a ..... $e .. i have tried to echo these variables outside teh form but they dont work. i have also tried to echo them directly ie. $retrieve['question']; and this doesnt work either. could someone please advise what is wrong? cheers ps. i am new at this. this is my code. <?php include 'dbyear2.php'; $qnumber = ($_REQUEST['uqn']); // obtain question number from URL $find = mysqli_query($condbyear2, "SELECT * FROM Renal WHERE UQN='$qnumber'"); while($retrieve=mysqli_fetch_row($find)); { $question = $retrieve['question']; $a = $retrieve['MCQ_A']; $b = $retrieve['MCQ_B']; $c = $retrieve['MCQ_C']; $d = $retrieve['MCQ_D']; $e = $retrieve['MCQ_E']; $answer = $retrieve['answer']; $correct = $retrieve['MCQ_correct']; } ?> <form action='check.php' method='POST'> <table> <tr><td></td><td></td></tr> <tr></tr> <tr><td><input type='radio' name='group1' value='A' /></td><td> <?php echo $a; ?></td></tr> <tr><td><input type='radio' name='group1' value='B' /></td><td> <?php echo $b; ?></td></tr> <tr><td><input type='radio' name='group1' value='C' /></td><td> <?php echo $c; ?></td></tr> <tr><td><input type='radio' name='group1' value='D' /></td><td> <?php echo $d; ?></td></tr> <tr><td><input type='radio' name='group1' value='E' /></td><td> <?php echo $e; ?></td></tr> <tr> <?php // sending the retrieved information from MYSQL via POST for use in check.php file $qnumber; $a; $b; $c; $d; $e; $answer; $correct; ?></tr> <tr><td><input type="submit" value="Submit"></td></tr> </table> </form>
  6. Oh dear.. What do you mean by not being secure? - as in people will be able to login without registering or something worse? Also, I get the impression I need to start all over again for creating my membership system. Could you please advise on a tutorial I could follow?
  7. Hey guys. i'm new at coding and need some help. I'm tryin to get my site to say "Welcome, $first_name $surname ! .... etc etc" after the individual logs in and it's not working for some mysterious reason. Currently, it's saying everything else I want it to but it's ommiting the $first_name and $surname fields that i want it to show. Could someone please let me know why its not working and how I can fix it. Thanks. Here's what I've got: this file below is called checkuser.php <? /* Check User Script */ session_start(); // Start Session include 'db.php'; // Conver to simple variables $email_address = $_POST['email_address']; $password = $_POST['password']; if((!$email_address) || (!$password)){ echo "Please enter ALL of the information! <br />"; include 'login_form.html'; exit(); } // Convert password to md5 hash !!!!DELETED!!!! - for security reasons // check if the user info validates the db $sql = mysql_query("SELECT * FROM users WHERE email_address='$email_address' AND password='$password' AND email_activated='1'"); $login_check = mysql_num_rows($sql); if($login_check > 0){ while($row = mysql_fetch_array($sql)){ foreach( $row AS $key => $val ){ $$key = stripslashes( $val ); } // Register some session variables! session_register('first_name'); $_SESSION['first_name'] = $first_name; session_register('surname'); $_SESSION['surname'] = $surname; session_register('email_address'); $_SESSION['email_address'] = $email_address; session_register('special_userY1'); $_SESSION['account_type'] = $account_type; mysql_query("UPDATE users SET last_login=now() WHERE userid='$userid'"); header("Location: login_success.php"); } } else { echo "You could not be logged in! Either the email_address and password do not match or you have not validated your membership!<br /> Please try again!<br />"; include 'login_form.html'; } ?> this file below is called login_success.php <? session_start(); echo "Welcome ". $_SESSION['first_name'] ." ". $_SESSION['surname'] ."! You have made it to the members area!<br /><br />"; echo "Your user level is ". $_SESSION['account_type']." which enables you access to the following areas: <br />"; if($_SESSION['account_type'] == 1){ echo "- Forums<br />- Chat Room<br />"; } if($_SESSION['account_type'] == 2){ echo "- Forums<br />- Chat Room<br />- Moderator Area<br />"; } echo "<br /><a href=logout.php>Logout</a>"; ?>
×
×
  • 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.