Guest User

insert into mysql problem

a guest
Feb 26th, 2012
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. $connect= mysql_connect("localhost","root") or die ("Sorry, Can not connect to database");
  2.  
  3. mysql_select_db("login") or die (mysql_error());
  4.  
  5. $user=$_POST['staff'];
  6. echo $user;
  7.  
  8. $query="SELECT * from users where username='$user' ";
  9. $result=mysql_query($query,$connect) or die(mysql_error());
  10. $row=mysql_fetch_array($result);
  11.  
  12. $uid=$row['userid'];
  13. echo $uid;
  14.  
  15. $query="SELECT * from opt where userid='$uid' ";
  16. $result=mysql_query($query,$connect) or die(mysql_error());
  17. $row=mysql_fetch_array($result);
  18.  
  19. if($row['confirm']==0)
  20. {
  21.  
  22. $query = "INSERT INTO opt (confirm) values(1)";
  23. echo 'The user selected options has confirmed';
  24.  
  25.  
  26. }
  27. ?>
  28.  
  29. mysql_query($query);
  30.  
  31. mysql_query($query);
  32.  
  33. $user = mysql_real_escape_string($user);
Add Comment
Please, Sign In to add comment