Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. FRONT
  2. <?php
  3. $post = 'name='.$name;////(set name above))
  4.  
  5. $url = "#######/Middle/chooseTestMiddle.php";
  6.  
  7. $ch = curl_init();//initialize
  8.  
  9. curl_setopt($ch, CURLOPT_URL, $url);
  10. curl_setopt($ch, CURL_POST, true); //true = 1
  11. curl_setopt($ch, CURLOPT_POSTFIELDS, $post);//post is the date of name value pair
  12. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);//get data bak = true
  13.  
  14. $response = curl_exec($ch); //execute and get back data
  15.  
  16. curl_close($ch);// close all curl connections
  17.  
  18. $a = json_decode($response);
  19.  
  20. var_dump($a);
  21.  
  22. ?>
  23.  
  24. <?php
  25.  
  26.  
  27. // $result = $a[0][0];
  28. // $onoroff = $a[1];
  29.  
  30. // echo $result;
  31.  
  32. if(mysqli_num_rows($result)>0)
  33. {
  34. while($row = mysqli_fetch_assoc($result))
  35. {
  36. echo '<form action="takeTest.php" method = "post" role="form"><button '.$onoroff.' class="btn-xl btn-info" id="box" type="submit" name = "submit"><input type="hidden" name = "theExam" value ="'.$row[ExamName].'"></input><span style="font-size:40px; font-family: kodakku;" >'.$row[ExamName].'</span></button></form><br />';
  37. }
  38. }
  39. ?>
  40.  
  41. BACK
  42.  
  43. <?php
  44. include ('dbconnect.php');
  45.  
  46. $name = $_POST['name'];
  47.  
  48.  
  49. $a = "SELECT *
  50. FROM studentExams
  51. WHERE Username = '$name'";
  52. $b = mysqli_query($dbCon, $a);
  53. $c = mysqli_fetch_row($b);
  54.  
  55. $allPoints = $c[2]; //there is an answer1
  56.  
  57. if ($allPoints != "")
  58. $onoroff = "disabled";
  59. else
  60. $onoroff = " ";
  61.  
  62.  
  63. $sql = "SELECT ExamName FROM teacherExams";
  64. $result = mysqli_query($dbCon, $sql);
  65.  
  66. $theArray = array($result, $onoroff);
  67. echo json_encode($theArray);
  68.  
  69.  
  70. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement