Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if($_GET['msg'])
- {
- $uid=$_SESSION['userid'];
- $user=mysql_query("select * from tb_user where id=$uid");
- while($userData=mysql_fetch_array($user))
- {
- $uname=$userData['user_name'];
- $udept=$userData['dept_id'];
- $usr_typeid=$userData['user_type'];
- $upasswd=$userData['password'];
- }
- }
- if($_POST['submit'])
- {
- /*$updated=false;
- if($_POST['id']<>"")
- {
- $query="update tb_user set user_name='".$_POST['username']."',dept_id=".$_POST['dept_id'].",user_type=".$_POST['usertype'].",password='".$_POST['password']."' where id=".$_POST['id'];
- $updated=true;
- }
- else
- {
- $query="insert into tb_user(user_name,password,dept_id,user_type) values('".addslashes($_POST['username'])."','".addslashes($_POST['password'])."',".$_POST['dept_id'].",".$_POST['usertype'].")";
- }
- $result=mysql_query($query);
- if($updated)
- {
- $_SESSION['deptid']=$_POST['dept_id'];
- $_SESSION['usertype']=$_POST['usertype'];
- header("Location: index.php?msg=Record updated");
- }
- else
- {
- header("Location: index.php?msg=Record created");
- }*/
- header("Location:index.php?page=request");
- }
- ?>
- <form method="post">
- <input type="hidden" name="id" value="<?php echo $uid?>"></input><br>
- User Type:
- <select name="usertype">
- <?php
- $utype=mysql_query('select * from tb_usertype');
- while($userData=mysql_fetch_array($utype))
- {
- if($usr_typeid==$userData[0])
- {
- ?>
- <option value="<?php echo $userData['id'];?>" selected="selected"><?php echo $userData['name'];?></option>
- <?php
- }
- else
- {
- ?>
- <option value="<?php echo $userData['id'];?>"><?php echo $userData['name'];?></option>
- <?php
- }
- }
- ?>
- </select><br>
- User Name: <input type="text" name="username" value="<?php echo $uname?>"></input><br>
- Password: <input type="password" name="password" value="<?php echo $upasswd?>"></input><br>
- Department: <select name="dept_id">
- <?php
- $utype=mysql_query('select * from tb_dept');
- while($userData=mysql_fetch_array($utype))
- {
- if($udept==$userData[0])
- {
- ?>
- <option value="<?php echo $userData['id'];?>" selected="selected"><?php echo $userData['dept_name'];?></option>
- <?php
- }
- else
- {
- ?>
- <option value="<?php echo $userData['id'];?>"><?php echo $userData['dept_name'];?></option>
- <?php
- }
- }
- ?>
- </select><br>
- <input type="submit" name="submit" value="Add"></input>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement