SHARE
TWEET

Untitled

a guest May 22nd, 2017 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function showData(){
  5.     var data = window.dialogArguments;
  6.     html = "<table border='1' ><tr>";
  7.     for(i=0;i <data.length; i++){
  8.      html += "<td>" + data[i] + "<td>";
  9.     }
  10.     html+= "</tr></table>";
  11.     document.write(html);
  12.     }
  13. function InsertData(){
  14.     var data = window.dialogArguments;
  15.     //alert(data[0]);
  16.     document.studentData.fname.value= data[0];
  17.     document.studentData.sname.value= data[1];
  18.     document.studentData.gender.value= data[2];
  19.     document.studentData.dob.value= data[3];
  20.     document.studentData.flag.value= true;
  21.    
  22.     }
  23. function closeWindow(){
  24.     window.close();
  25. }  
  26. </script>
  27. </head>
  28. <body>
  29. <h1> Confirm Student Creation Data:<h1>
  30. <div>
  31. <script type="text/javascript">
  32. showData();
  33. </script>
  34. </div>
  35. <p>Are you sure this information is correct?<p>
  36. <form id="studentData" name="studentData" method="post" action="confirmCreation.php">
  37. <input type= "hidden" id = "flag" name="flag"/>
  38. <input type="hidden"id="fname" name="fn">
  39. <input type="hidden"id="sname" name="sn">
  40. <input type="hidden"id="gender" name="gen">
  41. <input type="hidden"id="dob" name="dob">
  42. <script type="text/javascript">
  43. InsertData();
  44. </script>
  45. <input type="submit" value="Create this Student"/>
  46. </form>
  47. </body>
  48. <?php
  49. $dbhost = "127.0.0.1";
  50. $dbuser = "root";
  51. $dbpass = "sohre3n";
  52. $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die  ('Error connecting to database');
  53. $dbname = "test";
  54. if(isset($_POST['flag'])){
  55. echo "building query...";
  56. mysql_select_db($dbname,$conn);
  57. $query = "INSERT INTO student ";
  58. $query .= "(ID, Name, Surname, Birthdate, Gender)";
  59. $query.= "VALUES (".createID($conn).", '".$_POST['fn']."', '".$_POST['sn']."', '".$_POST['dob']."', '".$_POST['gen']."');";
  60. $result = mysql_query($dbquery);
  61. echo " success?";
  62. echo $result;
  63. }
  64.  
  65. function createID($conn){
  66.     $tempquery = "SELECT ID FROM student;";
  67.     $result = mysql_query($tempquery,$conn);
  68.     $num = mysql_num_rows($result);
  69.     $num = $num + 1000;
  70.     return $num;
  71. }
  72. ?>
  73. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top