1
1
<?php
2
2
3
3
include ("connect.php " );
4
+ include ("forum_functions.php " );
4
5
5
6
$ username = $ _POST ['username ' ];
6
7
$ password = $ _POST ['password ' ];
7
8
9
+ $ minpl = 8 ;
10
+
8
11
/* echo "Registeration Details : ";
9
12
echo "Username : " . $username . "<br/><br/> Password : " . $password; */
10
-
11
- $ sql = "INSERT INTO forum.users(username , password)
12
- VALUES (' $ username' , ' $ password');
13
- " ;
14
-
15
- $ res = mysqli_query ($ link , $ sql );
16
13
17
- if ( $ res ){
18
- echo "<b>Successfully Registered</b> as : " . $ username . " <br/> <br/> " ;
14
+ if ( $ username == "" || $ password == "" ){
15
+ echo "Please fill in all the details <br/> Please check if you forgot to enter data in any of the fields <br/> " ;
19
16
}
17
+
20
18
else {
21
- echo "<b>Registration Failed</b><br/><br/> " ;
22
- echo "Error is => " . mysql_error ();
19
+ if ( checkInvalidCharacters ($ username ) )
20
+ echo "Username can only contain <br/><br/><ul><li> A to Z </li><li> a to z </li><li> 0 to 9 </li><li> . and _ </li></ul> " ;
21
+
22
+ else {
23
+ if (strlen ($ password ) >= $ minpl ) {
24
+
25
+ $ sql = "INSERT INTO forum.users(username , password)
26
+ VALUES (' $ username' , ' $ password');
27
+ " ;
28
+
29
+ $ res = mysqli_query ($ link , $ sql );
30
+
31
+ if ($ res ){
32
+ echo "<b>Successfully Registered</b> as : " . $ username . "<br/><br/> " ;
33
+ }
34
+
35
+ else {
36
+ echo "<b>Registration Failed</b><br/><br/> " ;
37
+ echo "Error is => " . mysql_error ();
38
+ }
39
+
40
+
41
+ }
42
+
43
+ else {
44
+ echo "Password is too short. <br/> <b>Minimum length is 8 characters</b> " ;
45
+ }
46
+ }
23
47
}
48
+
24
49
25
50
?>
0 commit comments