Advertisement
Guest User

Untitled

a guest
Jun 9th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.92 KB | None | 0 0
  1. <?php
  2. $local = 'localhost';
  3. $user = 'root';
  4. $pass = '';
  5. $db = 'popgroep';
  6. //Try to connect
  7. $conn = new mysqli($local,$user,$pass,$db);
  8. if(mysqli_connect_errno()){
  9. printf("Connect failed: ",mysqli_connect_error);
  10. exit();
  11. }
  12.  
  13. $select_popgroep = "SELECT pop_id, pop_naam FROM popgroep";
  14. $result = mysqli_query($conn,$select_popgroep);
  15. if(!$result){
  16. echo "Error SELECT " . mysqli_error();
  17. }
  18.  
  19. if(isset($_POST['submit'])){
  20. if(!empty($_POST['pop'])) {
  21. $email = $_POST['email'];
  22. if(!empty($email)){
  23. echo "<span>You have selected :</span><br/>";
  24. //As output of $_POST['pop'] is an array we have to use foreach Loop to display individual value
  25.  
  26. foreach ($_POST['pop'] as $select){
  27. $results = mysqli_query($conn, "SELECT pop_naam FROM popgroep WHERE pop_naam = '".$select."'");
  28. $num = mysqli_query($conn, "SELECT pop_id FROM popgroep WHERE pop_naam = '".$select."'");
  29. $lezen = mysqli_fetch_array($num);
  30.  
  31. while($rows = mysqli_fetch_array($results)){
  32. if($select == $rows['pop_naam']){
  33. $st_email = mysqli_query($conn,"SELECT st_mail FROM stemmer WHERE st_mail = '".$email."'");
  34. $c_email = mysqli_num_rows($st_email);
  35. if($c_email==0){
  36. //STEMMER
  37. $insert_st = mysqli_query($conn,"INSERT INTO stemmer (st_id,st_mail)
  38. VALUE ('','$email')");
  39. if($insert_st){ echo "EMAIL INSERTED TO STEMMER</br>";}
  40. }
  41.  
  42. $top_1 = mysqli_query($conn, "SELECT st_id FROM stemmer WHERE st_mail = '".$email."'");
  43.  
  44.  
  45. //SELECT st_id FROM pop_regel
  46. //$st_id_regel = mysqli_query($conn,"SELECT st_id FROM pop_regel,stemmer WHERE mail = '".$email."'");
  47. //$st_id_regels = mysqli_num_rows($st_id_regel);
  48. //echo $st_id_regels;
  49.  
  50. //SELECT LAST STEMMER ID
  51. $select_st = mysqli_query($conn,"SELECT st_id FROM stemmer ORDER BY st_id DESC LIMIT 1");
  52. $control_st = mysqli_fetch_array($select_st);
  53. echo $control_st['st_id'];
  54.  
  55.  
  56.  
  57.  
  58. //INSERT INTO pop_regel
  59. $insert = mysqli_query($conn, "INSERT INTO pop_regel (st_pop_id,st_id,pop_id,score)
  60. VALUE ('','".$control_st['st_id']."','".$lezen['pop_id']."','7')");
  61. if($insert){
  62. echo "You voted once";
  63. }//if
  64.  
  65.  
  66.  
  67. /*
  68. //INSERT INTO pop_regel
  69. $insert = mysqli_query($conn, "INSERT INTO pop_regel (st_pop_id,st_id,pop_id,score)
  70. VALUE ('','".$control_st['st_id']."','".$lezen['pop_id']."','5')");
  71. if($insert) {echo "You voted twice";}
  72.  
  73.  
  74. //INSERT INTO pop_regel
  75. $insert = mysqli_query($conn, "INSERT INTO pop_regel (st_pop_id,st_id,pop_id,score)
  76. VALUE ('','".$control_st['st_id']."','".$lezen['pop_id']."','3')");
  77. if($insert) {echo "You voted three times";}
  78. */
  79.  
  80.  
  81.  
  82.  
  83. echo "<h4> POST eqeul pop_naam </h4>";
  84.  
  85. }//IF $select == $rows['pop_naam']
  86.  
  87. }//While
  88. }//Foreach
  89.  
  90.  
  91.  
  92.  
  93.  
  94. }//Email
  95. }//$_POST['pop']
  96. else
  97. { echo "<span>Please Select Atleast One pop.</span><br/>";}
  98. }//button
  99.  
  100. ?>
  101.  
  102. <!DOCTYPE html>
  103. <html>
  104. <head>
  105. <title>PHP Get Value of Select Option and Radio Button</title>
  106.  
  107. <!-- include css file here-->
  108. <link rel="stylesheet" href="css/style.css"/>
  109.  
  110. </head>
  111. <body>
  112. <div class="container">
  113. <div class="main">
  114. <form method="post" action="form.php">
  115. <?php include'select_value.php'; ?>
  116.  
  117. <!---------Select Option Fields starts here------>
  118. <select name="pop[]" multiple>
  119. <?php
  120. while($row = mysqli_fetch_array($result,MYSQL_BOTH)){
  121. ?>
  122. <option name='pop' value='<?php echo $row['pop_naam']?>'><?php echo $row['pop_naam']?></option>
  123. <?php
  124. }//end while
  125.  
  126. ?>
  127. </select><br/><br/>
  128. <hr/>
  129. </br>
  130. <input type="submit" name="submit" value="Uitvoeren" />
  131. <input type="text" name="email" placeholder="Uw Email"><br>
  132. </form>
  133. </div>
  134.  
  135. </div>
  136.  
  137. </body>
  138. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement