Advertisement
Guest User

Untitled

a guest
Apr 25th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. //Where my connection is.
  2. include ("global.php");
  3.  
  4.  
  5. $sql = "SELECT * FROM user_tb";
  6. $result = $conn->query($sql);
  7. $row = $result->fetch_assoc();
  8.  
  9. if($_POST)
  10. {
  11. if($username==null)
  12. {
  13. echo"<font face ='Trebuchet MS'><font color='black'><div class='content'>Please input required field.</div></font>";
  14.  
  15. }
  16.  
  17. elseif($result->num_rows==$row['username'])
  18. {
  19. echo"<font face ='Trebuchet MS'><font color='black'><div class='content'>Username already exist.</div></font>";
  20.  
  21. }
  22.  
  23.  
  24. elseif($password==null)
  25. {
  26. echo"<font face ='Trebuchet MS'><font color='black'><div class='content'>Please input required field.</div></font>";
  27.  
  28. }
  29.  
  30.  
  31. else if($password!==$retypepassword)
  32.  
  33. {
  34. echo "<font face ='Trebuchet MS'><font color='black'><div class='content'>Password Does not Match. </div></font>";
  35. }
  36.  
  37.  
  38. else if (strlen($password < 5 ))
  39. {
  40. echo"<font face ='Trebuchet MS'><font color='black'><div class='content'>Password must contain at least 8-10 characters.</div></font>";
  41.  
  42. }
  43.  
  44.  
  45. else if($fname==null)
  46.  
  47. {
  48. echo "<font face ='Trebuchet MS'><font color='black'><div class='content'>Please input required field.</div> </font>";
  49. }
  50.  
  51. else if($type==null)
  52.  
  53. {
  54. echo "<font face ='Trebuchet MS'><font color='black'><div class='content'>Please input required field. </div></font>";
  55. }
  56.  
  57.  
  58. else if ($type=="mis")
  59.  
  60.  
  61. {
  62.  
  63.  
  64. $none="mis";
  65.  
  66. $sql = "INSERT INTO user_tb (username , password , type ,branch , name ) VALUES ('$username' , '$password' ,'$type' , '$none' , '$fname')";
  67. $conn->query($sql);
  68.  
  69.  
  70. echo " <script type="text/javascript">
  71.  
  72. alert('New User Added');
  73. window.close();
  74.  
  75. </script>
  76. ";
  77. }
  78.  
  79.  
  80.  
  81. else if ($type=="warehouse")
  82.  
  83. {
  84.  
  85. $none="warehouse";
  86.  
  87. $sql = "INSERT INTO user_tb (username , password , type ,branch , name ) VALUES ('$username' , '$password' ,'$type' , '$none' , '$fname')";
  88. $conn->query($sql);
  89.  
  90.  
  91. echo " <script type="text/javascript">
  92.  
  93. alert('New User Added');
  94. window.close();
  95.  
  96. </script>
  97. ";
  98. }
  99.  
  100.  
  101. else {
  102.  
  103.  
  104.  
  105.  
  106.  
  107. $sql = "INSERT INTO user_tb (username , password , type ,branch , name ) VALUES ('$username' , '$password' ,'$type' , '$user' , '$fname')";
  108. $conn->query($sql);
  109.  
  110. echo " <script type="text/javascript">
  111.  
  112. alert('New User Added');
  113. window.close();
  114.  
  115. </script>
  116. ";
  117.  
  118.  
  119. }
  120. }
  121.  
  122. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement