Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <center><br/><h2>Update Form</h2></center>
- <div id="login">
- <fieldset>
- <legend><h3>Update Form</h3></legend>
- <h4 style="color:pink;"><?php global $nam; echo $nam;?> </h4>
- <?php global $error; echo $error;?>
- <!-- the login form-->
- <form action='login_reg_action.php' method='post' id='myform'>
- <div class="login">
- <table width="400px">
- <tr>
- <td><label>Username</label></td>
- <td colspan="2"><span class="style8">
- <div align="center">
- <?php
- include 'connection.php';
- $sql = 'SELECT * FROM login_1 ORDER BY username';
- $sele=mysqli_query($conn,$sql);
- ?>
- <select name="login_id" style="width:250px; height:34px; border:1px solid #336666;">
- <option required="required" value="000" > [SELECT STUDENT]</option>
- <?php
- while($numu=mysqli_fetch_array($sele))
- {
- ?>
- <option required="required" value="<?php echo $numu['login_id'];?> "> <?php echo $numu["login_id"];echo' - ';echo $numu["username"] ?> </option>
- <?php
- }
- ?>
- </select>
- </label>
- </div>
- </td>
- </tr>
- <tr>
- <td><label>Rank</label></td>
- <td><select name="rank" id="rank" style="width:250px; height:34px; border:1px solid #336666;">
- <option value="000">Choose user rank</option>
- <option value="student">Student</option>
- <option value="candidate">Candidate</option>
- <option value="administrator">Administrator</option>
- </select></td>
- </tr>
- <tr><td colspan="2" align="left"><input type="submit" name="submit" value="Update" style="width:100px; height:34px; border:1px solid #336666; border-radius:4px;"></td></tr>
- </table>
- </div>
- </form>
- <?php
- $servername="localhost";
- $username="root";
- $password="";
- $dbname="o-voting_db";
- //Create connection
- $con=mysqli_connect($servername,$username,$password,$dbname);
- $name = $_POST['login_id'];
- $rank = $_POST['rank'];
- if(!$name || !$rank){
- $error="Please fill empty fields";
- include"login_reg.php";
- exit();
- }
- if(isset($_POST['submit'])) {
- $sql1="UPDATE login_1 SET rank='$rank' WHERE username='$name'";
- // if($rank=='candidate'){
- //include 'reg_cand.php';
- //}
- $result = mysqli_query($con,$sql1)or die(mysqli_error($sql1));
- if(!$result){
- die("Could not update data: " .mysqli_error($con));
- }
- else{
- $nam="<center><h4><font color='#00FF00'>Successful update,</h4></center> </font>";
- include "login_reg.php";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement