Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $local = 'localhost';
- $user = 'root';
- $pass = '';
- $db = 'popgroep';
- //Try to connect
- $conn = new mysqli($local,$user,$pass,$db);
- if(mysqli_connect_errno()){
- printf("Connect failed: ",mysqli_connect_error);
- exit();
- }
- $select_popgroep = "SELECT pop_id, pop_naam FROM popgroep";
- $result = mysqli_query($conn,$select_popgroep);
- if(!$result){
- echo "Error SELECT " . mysqli_error();
- }
- if(isset($_POST['submit'])){
- if(!empty($_POST['pop'])) {
- $email = $_POST['email'];
- if(!empty($email)){
- echo "<span>You have selected :</span><br/>";
- //As output of $_POST['pop'] is an array we have to use foreach Loop to display individual value
- foreach ($_POST['pop'] as $select){
- $results = mysqli_query($conn, "SELECT pop_naam FROM popgroep WHERE pop_naam = '".$select."'");
- $num = mysqli_query($conn, "SELECT pop_id FROM popgroep WHERE pop_naam = '".$select."'");
- $lezen = mysqli_fetch_array($num);
- while($rows = mysqli_fetch_array($results)){
- if($select == $rows['pop_naam']){
- $st_email = mysqli_query($conn,"SELECT st_mail FROM stemmer WHERE st_mail = '".$email."'");
- $c_email = mysqli_num_rows($st_email);
- if($c_email==0){
- //STEMMER
- $insert_st = mysqli_query($conn,"INSERT INTO stemmer (st_id,st_mail)
- VALUE ('','$email')");
- if($insert_st){ echo "EMAIL INSERTED TO STEMMER</br>";}
- }
- $top_1 = mysqli_query($conn, "SELECT st_id FROM stemmer WHERE st_mail = '".$email."'");
- //SELECT st_id FROM pop_regel
- //$st_id_regel = mysqli_query($conn,"SELECT st_id FROM pop_regel,stemmer WHERE mail = '".$email."'");
- //$st_id_regels = mysqli_num_rows($st_id_regel);
- //echo $st_id_regels;
- //SELECT LAST STEMMER ID
- $select_st = mysqli_query($conn,"SELECT st_id FROM stemmer ORDER BY st_id DESC LIMIT 1");
- $control_st = mysqli_fetch_array($select_st);
- echo $control_st['st_id'];
- //INSERT INTO pop_regel
- $insert = mysqli_query($conn, "INSERT INTO pop_regel (st_pop_id,st_id,pop_id,score)
- VALUE ('','".$control_st['st_id']."','".$lezen['pop_id']."','7')");
- if($insert){
- echo "You voted once";
- }//if
- /*
- //INSERT INTO pop_regel
- $insert = mysqli_query($conn, "INSERT INTO pop_regel (st_pop_id,st_id,pop_id,score)
- VALUE ('','".$control_st['st_id']."','".$lezen['pop_id']."','5')");
- if($insert) {echo "You voted twice";}
- //INSERT INTO pop_regel
- $insert = mysqli_query($conn, "INSERT INTO pop_regel (st_pop_id,st_id,pop_id,score)
- VALUE ('','".$control_st['st_id']."','".$lezen['pop_id']."','3')");
- if($insert) {echo "You voted three times";}
- */
- echo "<h4> POST eqeul pop_naam </h4>";
- }//IF $select == $rows['pop_naam']
- }//While
- }//Foreach
- }//Email
- }//$_POST['pop']
- else
- { echo "<span>Please Select Atleast One pop.</span><br/>";}
- }//button
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>PHP Get Value of Select Option and Radio Button</title>
- <!-- include css file here-->
- <link rel="stylesheet" href="css/style.css"/>
- </head>
- <body>
- <div class="container">
- <div class="main">
- <form method="post" action="form.php">
- <?php include'select_value.php'; ?>
- <!---------Select Option Fields starts here------>
- <select name="pop[]" multiple>
- <?php
- while($row = mysqli_fetch_array($result,MYSQL_BOTH)){
- ?>
- <option name='pop' value='<?php echo $row['pop_naam']?>'><?php echo $row['pop_naam']?></option>
- <?php
- }//end while
- ?>
- </select><br/><br/>
- <hr/>
- </br>
- <input type="submit" name="submit" value="Uitvoeren" />
- <input type="text" name="email" placeholder="Uw Email"><br>
- </form>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement