I have a problem writing a user's grade to write my php quiz in a different file. It shows how many people were right / wrong, but it does not write the file What's wrong with my code, which will stop it, or am I missing something? Some creative inputs will be useful.
& lt ;? Php session_start (); #error_reporting (E_ALL); Ini_set ('display_errors', 1); Need_once ('connect.php'); Need_once "lib.php"; Need_once "utils.php"; $ Quiz_done = true; If (issued ($ _ session ['active'])) {$ email address = $ _SESSION ['emailaddress']; $ Sql = "Select * From user where email address = '$ email address''; if ($ result = mysqli_query ($ link, $ sql)) {while ($ row = mysqli_fetch_array ($ result, MYSQLI_ASSOC)) Quiz from {$ UserID = $ row ['UserID']; $ _SESSION ['UserID'] = $ UserID;}} $ UserID; $ Sql1 = "Select * where userID = '$ userID'"; $ Result1 = mysqli_query ( $ Link, $ sql1); if ($ result1) {while ($ record = mysqli_fetch_row ($ result1)) {if ($ record == $ UserID) {$ quiz_done = true; $ Sql = "Remove from quiz where User ID = '$ userID' "; $ result = mysqli_query ($ link, $ sql);} and {$ quiz_done = false;}}}} {header (" location: login.php ");}? & Gt; Lt; html & gt; & lt; top & Gt; & lt; title & gt; Quiz & lt; / title & gt; & lt; / head & gt; & lt; br & gt; & lt; / br & gt; & lt; br & gt; body class = "body">
& Lt; h1 & gt; PHP Learning Courses! & Lt; / h1 & gt; & lt; / br & gt; & lt ;? php include_once "left.php"? & Gt; & Lt; / Div & gt; & Lt; Div id = "quiz" & gt; & Lt; Div id = "quiz_name" & gt; & Lt; H3 & gt; PHP Learning Quiz & lt; / H3 & gt; & Lt; / Div & gt; & Lt; P & gt; & Lt; Div id = 'quiz1_form' & gt; & Lt ;? Php #function func ($ quiz_done) # {# if ($ quiz_done == true & $ session ['q_No']> gt; #) # header ("location: results.php"); #} #} Echo & lt; & Lt; & Lt; EOT & lt; FORM name = "quiz" id = "myQuiz" method = "post" action = "results.php" & gt; & Lt; Input type = "hidden" name = "Q & A" & gt; First name: & lt; Input type = "text" name = "fname" & gt; Last name: & lt; Input type = "text" name = "lname" & gt; & Lt; Br> & Lt; Pre & gt; 01. PHP is a closed source software. & Lt; / Pre & gt; True & lt; INPUT Type = "Radio" name = "Q1" value = "true" & gt; Wrong & lt; INPUT type = "radio" name = "Q1" value = "wrong" & gt; & Lt; / Br & gt; & Lt; Br> & Lt; Pre & gt; 02. PHP is a separate-side scripting language? & Lt; / Pre & gt; True & lt; INPUT type = "radio" name = "q2" value = "true" & gt; Wrong & lt; INPUT type = "radio" name = "Q2" value = "wrong" & gt; & Lt; / Br & gt; & Lt; Br> & Lt; Pre & gt; 03. Does PHP not support the database? & Lt; / Pre & gt; True & lt; INPUT Type = "Radio" name = "Q3" value = "true" & gt; Wrong & lt; INPUT type = "radio" name = "Q3" value = "wrong" & gt; & Lt; / Br & gt; & Lt; Br> & Lt; Pre & gt; 04. PHP can run on different platforms (ex, Windows, Linux and Unix)? & Lt; / Pre & gt; True & lt; INPUT Type = "Radio" name = "Q4" value = "true" & gt; Wrong & lt; INPUT type = "radio" name = "Q4" value = "wrong" & gt; & Lt; / Br & gt; & Lt; Br> & Lt; Pre & gt; 05. Can you use the format to take the input from the user and store that information in the database or file? & Lt; / Pre & gt; True & lt; INPUT Type = "Radio" name = "Q5" value = "true" & gt; Wrong & lt; INPUT type = "radio" name = "Q5" value = "wrong" & gt; & Lt; / Br & gt; & Lt; P & gt; & Lt; Input id = "subboot" type = "submit" value = "submit form" & gt; & Lt; INPUT ID = "subbut" TYPE = "reset" VALUE = "clear form" & gt; & Lt; / P & gt; & Lt; / Form & gt; EOT; ? & Gt; & Lt; / P & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt ;! - End main div - & gt; & Lt; / Div & gt; & Lt ;! - End Cover Div - & gt; & Lt; / Body & gt; & Lt; / Html & gt;
There is nothing to write a file here I
write public functiongrad () {$ content = "" $ Userid Seeing "results"; $ Content = "". $ Your grade ""; $ Content = "\ R \ n"; $ Fp = fopen ($ _ server ['DOCUMENT_ROOT']. "/".$userid.".txt", "wb"); Fwrite ($ fp, $ content); Fclose ($ FP); }
This is very common, but you should be able to customize your needs in the suite.
No comments:
Post a Comment