SHOW:
|
|
- or go back to the newest paste.
1 | <?php | |
2 | ||
3 | include 'database.php'; | |
4 | // create a variable | |
5 | if($_SERVER["REQUEST_METHOD"]=="POST") | |
6 | { | |
7 | $username = mysql_real_escape_string($_POST['username']); | |
8 | $password = mysql_real_escape_string($_POST['password']); | |
9 | $idrole=$_POST['idrole']; | |
10 | $name=$_POST['name']; | |
11 | $icno=$_POST['icno']; | |
12 | $address=$_POST['address']; | |
13 | $postcode=$_POST['postcode']; | |
14 | $phone=$_POST['phone']; | |
15 | $email=$_POST['email']; | |
16 | $bool = true; | |
17 | //Execute the query | |
18 | ||
19 | - | $query2 = mysql_query("SELECT * FROM employee WHERE username= '$username'"); |
19 | + | $query2 = mysql_query("SELECT * FROM employee WHERE username = '$username'"); |
20 | - | if(mysql_num_rows($query2)>=1) |
20 | + | if(mysql_num_rows($query2) == 0 ) |
21 | { | |
22 | - | Print '<script>alert("Username has been taken !");</script>'; |
22 | + | mysqli_query($connect, "INSERT INTO employee |
23 | - | Print '<script>window.location.assign("login.php");</script>'; |
23 | + | |
24 | ||
25 | if(mysqli_affected_rows($connect) > 0) | |
26 | { | |
27 | - | mysqli_query($connect, "INSERT INTO employee |
27 | + | |
28 | Print '<script>window.location.assign("login.php");</script>'; | |
29 | }else { | |
30 | Print '<script>alert("Profile Not Added !");</script>'; | |
31 | echo mysqli_error ($connect); | |
32 | } | |
33 | ||
34 | ||
35 | } | |
36 | else | |
37 | { | |
38 | Print '<script>alert("Username has been taken !");</script>'; | |
39 | Print '<script>window.location.assign("login.php");</script>'; | |
40 | } | |
41 | ||
42 | mysqli_close($connect); | |
43 | } | |
44 | ||
45 | ?> |