Guest User

Untitled

a guest
Aug 9th, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. How to link to this to the database
  2. AAA
  3. AAB
  4. ABA
  5. ABB
  6. BAA
  7. BAB
  8. BBA
  9. BBB
  10.  
  11. Session Id
  12.  
  13. AAA
  14. AAB
  15.  
  16. <?php
  17.  
  18. $username="xxxxxxxxxxx";
  19. $password="xxxxxx";
  20. $database="mobile_app";
  21.  
  22. mysql_connect('localhost',$username,$password);
  23. @mysql_select_db($database) or die("Unable to select database");
  24.  
  25. foreach (array('courseid') as $varname) {
  26. $courseid = (isset($_POST[$varname])) ? $_POST[$varname] : '';
  27. }
  28.  
  29. ?>
  30.  
  31.  
  32. <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
  33. <p>Course ID: <input type="text" name="courseid" value="<?php echo $courseid; ?>" /><input type="submit" value="Submit" name="submit" /></p> <!-- Enter User Id here-->
  34. </form>
  35.  
  36. <?php
  37. if (isset($_POST['submit'])) {
  38. $query = "
  39. SELECT cm.CourseId, cm.ModuleId,
  40. c.CourseName,
  41. m.ModuleName
  42. FROM Course c
  43. INNER JOIN Course_Module cm ON c.CourseId = cm.CourseId
  44. JOIN Module m ON cm.ModuleId = m.ModuleId
  45. WHERE
  46. (c.CourseId = '".mysql_real_escape_string($courseid)."')
  47. ORDER BY c.CourseName, m.ModuleId
  48. ";
  49.  
  50.  
  51.  
  52. $num = mysql_num_rows($result = mysql_query($query));
  53. mysql_close()
  54.  
  55. ;
  56. ?>
  57.  
  58. <?php
  59.  
  60. $username=xxx";
  61. $password="xxx";
  62. $database="mobile_app";
  63.  
  64.  
  65. $is_there = true;
  66.  
  67. $con = mysql_connect('localhost',$username,$password);
  68. @mysql_select_db($database, $con) or die("Unable to select database");
  69.  
  70. while( $is_there ){
  71. $id = id_generator(); // your function to generate id;
  72. $result = mysql_query( "SELECT SessionId FROM Session WHERE SessionId = '$id'" );
  73. if( mysql_num_rows( $result ) == 0 ) $is_there = false;
  74. }
  75.  
  76.  
  77.  
  78.  
  79. foreach (array('courseid', 'sessionid') as $varname) {
  80. $$varname = (isset($_POST[$varname])) ? $_POST[$varname] : '';
  81. }
  82.  
  83. ?>
  84.  
  85. <h1>CREATING A SESSION</h1>
  86.  
  87. <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
  88. <p>Course ID: <input type="text" name="courseid" value="<?php echo $courseid; ?>" /><input type="submit" value="Submit" name="submit" /></p> <!-- Enter User Id here-->
  89. </form>
  90.  
  91. <?php
  92. if (isset($_POST['submit'])) {
  93. $query = "
  94. SELECT cm.CourseId, cm.ModuleId,
  95. c.CourseName,
  96. m.ModuleName
  97. FROM Course c
  98. INNER JOIN Course_Module cm ON c.CourseId = cm.CourseId
  99. JOIN Module m ON cm.ModuleId = m.ModuleId
  100. WHERE
  101. (c.CourseId = '".mysql_real_escape_string($courseid)."')
  102. ORDER BY c.CourseName, m.ModuleId
  103. ";
  104.  
  105. $num = mysql_num_rows($result = mysql_query($query));
  106. mysql_close();
  107.  
  108. $is_there = true;
  109.  
  110. $con = mysql_connect( address , user, pass );
  111. mysql_select_db( DATABASE , $con );
  112.  
  113. while( $is_there ){
  114. $id = id_generator(); // your function to generate id;
  115. $result = mysql_query( "SELECT * FROM your_table WHERE id = '$id'" );
  116. if( mysql_num_rows( $result ) == 0 ) $is_there = false;
  117. }
  118.  
  119. <?php
  120.  
  121. ...
  122. @mysql_select_db($database) or die("Unable to select database");
  123. $courseid = "";
  124. while( $is_there ){
  125. $courseid = id_generator(); // your function to generate id;
  126. $query = "
  127. SELECT cm.CourseId, cm.ModuleId,
  128. c.CourseName,
  129. m.ModuleName
  130. FROM Course c
  131. INNER JOIN Course_Module cm ON c.CourseId = cm.CourseId
  132. JOIN Module m ON cm.ModuleId = m.ModuleId
  133. WHERE
  134. (c.CourseId = '".mysql_real_escape_string($courseid)."')
  135. ORDER BY c.CourseName, m.ModuleId
  136. ";
  137.  
  138. if( mysql_num_rows( $result = mysql_query($query) ) == 0 ) $is_there = false;
  139. }
  140. mysql_close();
  141. echo "You generated code id: " . $courseid;
  142.  
  143. ?>...
Add Comment
Please, Sign In to add comment