probleem met activerings code
volgende code in register.php
"$email1 = mysql_real_escape_string($email1);
$pass1 = mysql_real_escape_string($pass1);
$code = rand(23456789, 99999999);
$pass = md5 ($password);
$full_birthday = "$b_y-$b_m-$b_d";
$ipaddress = getenv('REMOTE_ADDR');
$sql = mysql_query("INSERT INTO meetyourpal2 (username, gender, birthday, email, password, ipaddress, sign_up_date, code)
VALUES('$username','$gender','$full_birthday','$email1','$db_password', '$ipaddress', '$code', now())") "
De volgende code zie ik in mijn database
code 2011
code 2011
Wie kan mij helpen, groetjes en alvast bedankt,peter
Gewijzigd op 31/01/2011 16:33:13 door Ozzie PHP
Code (php)
1
2
2
$sql = mysql_query("INSERT INTO meetyourpal2 (username, gender, birthday, email, password, ipaddress, sign_up_date, code)
VALUES('$username','$gender','$full_birthday','$email1','$db_password', '$ipaddress', '$code', now())") "
VALUES('$username','$gender','$full_birthday','$email1','$db_password', '$ipaddress', '$code', now())") "
Wordt dus:
dus VALUES($username, $gender, enz.)
wat nu?
Peter druyts op 31/01/2011 17:03:19:
Ha, wat leuk dat je mij ook even bedankt.dank je dutch guy, dit is opgelost
sorry ozzi, had dit geplaatst voor ik jou bericht kreeg
Ozzie PHP op 31/01/2011 16:56:35:
Je moet ook je variabelen niet tussen quotes zetten bij values...
dus VALUES($username, $gender, enz.)
dus VALUES($username, $gender, enz.)
Wel tussen de enkele maar uit de dubbele quotes.
dus ... "INSERT .... VALUES('" . $username . "', '" . $gender . "', enz.)
En denk aan sql-injection.
Gewijzigd op 31/01/2011 17:14:53 door - SanThe -
Code (php)
1
2
3
4
5
6
2
3
4
5
6
UPDATE
user
SET
geactiveerd = 1
WHERE
activatiecode = '".mysql_real_escape_string( $_GET['code'] )."'
user
SET
geactiveerd = 1
WHERE
activatiecode = '".mysql_real_escape_string( $_GET['code'] )."'
Dat zou dan ongeveer je opzet worden. Je zou het ook zo kunnen doen:[b
Database:
activated
- user_id
- activate_code
User
- id
- username
- password
- name
etc etc.
En dan de regel uit de activated tabel halen als je geactiveerd bent. Tis maar een idee hoor (A).
@ Ozzie: En dit gaat waarover?
- SanThe - op 31/01/2011 17:14:19:
moet dat per se tussen quotes? Zou het zonder niet werken?Wel tussen de enkele maar uit de dubbele quotes.
dus ... "INSERT .... VALUES('" . $username . "', '" . $gender . "', enz.)
dus ... "INSERT .... VALUES('" . $username . "', '" . $gender . "', enz.)
@Milo: huh? U zegt?
Vraagje, kan het zijn, omdat ik in mijn database de emailactivated heb staan dat ik dan in de php van UPDATE het ook moet gebruiken,
Ozzie en Santhe bedankt, heb het ingebracht
Ozzie PHP op 31/01/2011 17:58:20:
- SanThe - op 31/01/2011 17:14:19:
moet dat per se tussen quotes? Zou het zonder niet werken?Wel tussen de enkele maar uit de dubbele quotes.
dus ... "INSERT .... VALUES('" . $username . "', '" . $gender . "', enz.)
dus ... "INSERT .... VALUES('" . $username . "', '" . $gender . "', enz.)
Probeer het eens zou ik zeggen. ;-)
SQL zal dan denken dat het een veldnaam is o.i.d. en zal een error geven.
oh oke... bij PDO (prepared statements) kan ik me niet herinneren dat ik de waardes tussen quotes zet eigenlijk...
Ozzie PHP op 31/01/2011 19:08:19:
oh oke... bij PDO (prepared statements) kan ik me niet herinneren dat ik de waardes tussen quotes zet eigenlijk...
Inderdaad, dat hoeft niet, want je stuurt de query en de data los van elkaar naar de database.
Oke, ik snap het nu. Thanks Karl.
de activatiecode = '".mysql_real_escape_string( $_GET['code'] )."' met telkens een ander error, of hij herkend de code niet, of de username en passwoord is fout, en nu is het zo dat het passwoord niet in de database wordt ingevuld. Waar ik ook nog geen oplossing voor heb, heb ik jullie niet verteld is dat de activerings email wordt verstuurd onder de naam "Mail failure - malformed recipient address" vanuit mijn email account van mijn database.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
$from = "";
if (isset ($_POST['username'])){
$username = preg_replace('#[^A-Za-z0-9]#i', '', $_POST['username']);
$gender = preg_replace('#[^a-z]#i', '', $_POST['gender']);
$b_m = preg_replace('#[^0-9]#i', '', $_POST['birth_month']);
$b_d = preg_replace('#[^0-9]#i', '', $_POST['birth_day']);
$b_y = preg_replace('#[^0-9]#i', '', $_POST['birth_year']);
$email1 = $_POST['email1'];
$email2 = $_POST['email2'];
$pass1 = $_POST['pass1'];
$pass2 = $_POST['pass2'];
$humancheck = $_POST['humancheck'];
$email1 = stripslashes($email1);
$pass1 = stripslashes($pass1);
$email2 = stripslashes($email2);
$pass2 = stripslashes($pass2);
$email1 = strip_tags($email1);
$pass1 = strip_tags($pass1);
$email2 = strip_tags($email2);
$pass2 = strip_tags($pass2);
include_once "xxxxxxx.php";
$emailCHecker = mysql_real_escape_string($email1);
$emailCHecker = str_replace("`", "", $emailCHecker);
$sql_uname_check = mysql_query("SELECT username FROM meetyourpal2 WHERE username='$username'");
$uname_check = mysql_num_rows($sql_uname_check);
$sql_email_check = mysql_query("SELECT email FROM meetyourpal2 WHERE email='$emailCHecker'");
$email_check = mysql_num_rows($sql_email_check);
if ((!$username) || (!$gender) || (!$b_m) || (!$b_d) || (!$b_y) || (!$email1) || (!$email2) || (!$pass1) || (!$pass2)) {
$errorMsg = 'ERROR: You did not submit the following required information:<br /><br />';
if(!$username){
$errorMsg .= ' * User Name<br />';
}
if(!$gender){
$errorMsg .= ' * Gender: Confirm your sex.<br />';
}
if(!$b_m){
$errorMsg .= ' * Birth Month<br />';
}
if(!$b_d){
$errorMsg .= ' * Birth Day<br />';
}
if(!$b_y){
$errorMsg .= ' * Birth year<br />';
}
if(!$email1){
$errorMsg .= ' * Email Address<br />';
}
if(!$email2){
$errorMsg .= ' * Confirm Email Address<br />';
}
if(!$pass1){
$errorMsg .= ' * Login Password<br />';
}
if(!$pass2){
$errorMsg .= ' * Confirm Login Password<br />';
}
} else if ($email1 != $email2) {
$errorMsg = 'ERROR: Your Email fields below do not match<br />';
} else if ($pass1 != $pass2) {
$errorMsg = 'ERROR: Your Password fields below do not match<br />';
} else if ($humancheck != "") {
$errorMsg = 'ERROR: The Human Check field must be cleared to be sure you are human<br />';
} else if (strlen($username) < 4) {
$errorMsg = "<u>ERROR:</u><br />Your User Name is too short. 4 - 20 characters please.<br />";
} else if (strlen($username) > 20) {
$errorMsg = "<u>ERROR:</u><br />Your User Name is too long. 4 - 20 characters please.<br />";
} else if ($uname_check > 0){
$errorMsg = "<u>ERROR:</u><br />Your User Name is already in use inside of our system. Please try another.<br />";
} else if ($email_check > 0){
$errorMsg = "<u>ERROR:</u><br />Your Email address is already in use inside of our system. Please use another.<br />";
} else {
$email1 = mysql_real_escape_string($email1);
$pass1 = mysql_real_escape_string($pass1);
$code = rand(23456789, 99999999);
$pass = md5 ($password);
$full_birthday = "$b_y-$b_m-$b_d";
$ipaddress = getenv('REMOTE_ADDR');
$sql = mysql_query("INSERT INTO meetyourpal2 (username, gender, birthday, email, password, ipaddress, sign_up_date, code)
VALUES('$username','$gender','$full_birthday','$email1','$db_password', '$ipaddress', now())")
or die (mysql_error());
$id = mysql_insert_id();
mkdir("members/$id", 0755);
$to = $email;
$subject = "Activate your account";
$headers = "from: [email protected]";
$server = "mail.50webs.biz";
ini_set("SMTP",$server);
$body = "Hello $username,\n\nYou registered and need to activate your account. Click on the link below or paste it into the url bar of your browser \n\nhttp://mijn domeinnaam.php?code=$code\n\n
Thanks!";
mail($to, $subject, $message, $body, $headers);
die ("You have been registered! Check your email to activate your account<a href='login.php'> Go to Login page</a>");
$msgToUser = "<h2>One Last Step - Activate through Email</h2><h4>$username, there is one last step to verify your email identity:</h4><br />
In a moment you will be sent an Activation link to your email address.<br /><br />
<br />
<strong><font color=\"#990000\">VERY IMPORTANT:</font></strong>
If you check your email with your host providers default email application, there may be issues with seeing the email contents. If this happens to you and you cannot read the message to activate, download the file and open using a text editor.<br /><br />
";
include_once 'msgToUser.php';
exit();
}
} else {
$errorMsg = "";
$username = "";
$gender = "";
$b_m = "";
$b_d = "";
$b_y = "";
$email1 = "";
$email2 = "";
$pass1 = "";
$pass2 = "";
}
?>
if (isset ($_POST['username'])){
$username = preg_replace('#[^A-Za-z0-9]#i', '', $_POST['username']);
$gender = preg_replace('#[^a-z]#i', '', $_POST['gender']);
$b_m = preg_replace('#[^0-9]#i', '', $_POST['birth_month']);
$b_d = preg_replace('#[^0-9]#i', '', $_POST['birth_day']);
$b_y = preg_replace('#[^0-9]#i', '', $_POST['birth_year']);
$email1 = $_POST['email1'];
$email2 = $_POST['email2'];
$pass1 = $_POST['pass1'];
$pass2 = $_POST['pass2'];
$humancheck = $_POST['humancheck'];
$email1 = stripslashes($email1);
$pass1 = stripslashes($pass1);
$email2 = stripslashes($email2);
$pass2 = stripslashes($pass2);
$email1 = strip_tags($email1);
$pass1 = strip_tags($pass1);
$email2 = strip_tags($email2);
$pass2 = strip_tags($pass2);
include_once "xxxxxxx.php";
$emailCHecker = mysql_real_escape_string($email1);
$emailCHecker = str_replace("`", "", $emailCHecker);
$sql_uname_check = mysql_query("SELECT username FROM meetyourpal2 WHERE username='$username'");
$uname_check = mysql_num_rows($sql_uname_check);
$sql_email_check = mysql_query("SELECT email FROM meetyourpal2 WHERE email='$emailCHecker'");
$email_check = mysql_num_rows($sql_email_check);
if ((!$username) || (!$gender) || (!$b_m) || (!$b_d) || (!$b_y) || (!$email1) || (!$email2) || (!$pass1) || (!$pass2)) {
$errorMsg = 'ERROR: You did not submit the following required information:<br /><br />';
if(!$username){
$errorMsg .= ' * User Name<br />';
}
if(!$gender){
$errorMsg .= ' * Gender: Confirm your sex.<br />';
}
if(!$b_m){
$errorMsg .= ' * Birth Month<br />';
}
if(!$b_d){
$errorMsg .= ' * Birth Day<br />';
}
if(!$b_y){
$errorMsg .= ' * Birth year<br />';
}
if(!$email1){
$errorMsg .= ' * Email Address<br />';
}
if(!$email2){
$errorMsg .= ' * Confirm Email Address<br />';
}
if(!$pass1){
$errorMsg .= ' * Login Password<br />';
}
if(!$pass2){
$errorMsg .= ' * Confirm Login Password<br />';
}
} else if ($email1 != $email2) {
$errorMsg = 'ERROR: Your Email fields below do not match<br />';
} else if ($pass1 != $pass2) {
$errorMsg = 'ERROR: Your Password fields below do not match<br />';
} else if ($humancheck != "") {
$errorMsg = 'ERROR: The Human Check field must be cleared to be sure you are human<br />';
} else if (strlen($username) < 4) {
$errorMsg = "<u>ERROR:</u><br />Your User Name is too short. 4 - 20 characters please.<br />";
} else if (strlen($username) > 20) {
$errorMsg = "<u>ERROR:</u><br />Your User Name is too long. 4 - 20 characters please.<br />";
} else if ($uname_check > 0){
$errorMsg = "<u>ERROR:</u><br />Your User Name is already in use inside of our system. Please try another.<br />";
} else if ($email_check > 0){
$errorMsg = "<u>ERROR:</u><br />Your Email address is already in use inside of our system. Please use another.<br />";
} else {
$email1 = mysql_real_escape_string($email1);
$pass1 = mysql_real_escape_string($pass1);
$code = rand(23456789, 99999999);
$pass = md5 ($password);
$full_birthday = "$b_y-$b_m-$b_d";
$ipaddress = getenv('REMOTE_ADDR');
$sql = mysql_query("INSERT INTO meetyourpal2 (username, gender, birthday, email, password, ipaddress, sign_up_date, code)
VALUES('$username','$gender','$full_birthday','$email1','$db_password', '$ipaddress', now())")
or die (mysql_error());
$id = mysql_insert_id();
mkdir("members/$id", 0755);
$to = $email;
$subject = "Activate your account";
$headers = "from: [email protected]";
$server = "mail.50webs.biz";
ini_set("SMTP",$server);
$body = "Hello $username,\n\nYou registered and need to activate your account. Click on the link below or paste it into the url bar of your browser \n\nhttp://mijn domeinnaam.php?code=$code\n\n
Thanks!";
mail($to, $subject, $message, $body, $headers);
die ("You have been registered! Check your email to activate your account<a href='login.php'> Go to Login page</a>");
$msgToUser = "<h2>One Last Step - Activate through Email</h2><h4>$username, there is one last step to verify your email identity:</h4><br />
In a moment you will be sent an Activation link to your email address.<br /><br />
<br />
<strong><font color=\"#990000\">VERY IMPORTANT:</font></strong>
If you check your email with your host providers default email application, there may be issues with seeing the email contents. If this happens to you and you cannot read the message to activate, download the file and open using a text editor.<br /><br />
";
include_once 'msgToUser.php';
exit();
}
} else {
$errorMsg = "";
$username = "";
$gender = "";
$b_m = "";
$b_d = "";
$b_y = "";
$email1 = "";
$email2 = "";
$pass1 = "";
$pass2 = "";
}
?>
ik dank jullie bijvoorbaat
Toevoeging op 31/01/2011 23:45:21:
mijn activerings php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
$getcode = $_GET['code'];
$form = "<form action='xxxx.php' method='post'>
<table>
<tr>
<td>Activate Code:</td>
<td><input type='text' name='code' value='$getcode' size='10'></td>
</tr>
<tr>
<td>Username:</td>
<td><input type='text' name='username'></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='password'></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='submit' value='Activate'</td>
</tr>
</table>
</form>";
if ($_POST['submit']){
$code = strip_tags($_POST['code']);
$username = strip_tags($_POST['username']);
$password = strip_tags($_POST['password']);
if ($code && $username && $password){
if (strlen($code) == 8){
$pass = md5(md5($password));
require ('connect_to_database.php');
$query = mysql_query("SELECT * FROM meetyourpal2 WHERE username='$username' AND password='$pass'");
$numrows = mysql_num_rows($query);
if ($numrows == 1){
$row = mysql_fetch_assoc($query);
$dbcode = $row['code'];
if ($code == $dbcode){
mysql_query("UPDATE meetyourpal2 SET active='1' WHERE activation_code='".mysql_real_escape_string( $_GET['code'])."'");
echo "Your account has been activated. You may now login <a href='login.php'>Click here to login</a>";
}
else
echo "Your activation code was incorrect. $form";
}
else
echo "Your username and password are invalid. $form";
}
else
echo "You have not supplied a valid code. $form";
}
else
echo "You did not fill in the entire form. $form";
}
else
echo "$form";
?>
$form = "<form action='xxxx.php' method='post'>
<table>
<tr>
<td>Activate Code:</td>
<td><input type='text' name='code' value='$getcode' size='10'></td>
</tr>
<tr>
<td>Username:</td>
<td><input type='text' name='username'></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='password'></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='submit' value='Activate'</td>
</tr>
</table>
</form>";
if ($_POST['submit']){
$code = strip_tags($_POST['code']);
$username = strip_tags($_POST['username']);
$password = strip_tags($_POST['password']);
if ($code && $username && $password){
if (strlen($code) == 8){
$pass = md5(md5($password));
require ('connect_to_database.php');
$query = mysql_query("SELECT * FROM meetyourpal2 WHERE username='$username' AND password='$pass'");
$numrows = mysql_num_rows($query);
if ($numrows == 1){
$row = mysql_fetch_assoc($query);
$dbcode = $row['code'];
if ($code == $dbcode){
mysql_query("UPDATE meetyourpal2 SET active='1' WHERE activation_code='".mysql_real_escape_string( $_GET['code'])."'");
echo "Your account has been activated. You may now login <a href='login.php'>Click here to login</a>";
}
else
echo "Your activation code was incorrect. $form";
}
else
echo "Your username and password are invalid. $form";
}
else
echo "You have not supplied a valid code. $form";
}
else
echo "You did not fill in the entire form. $form";
}
else
echo "$form";
?>
Graag in het vervolg bij code, [code] [/code] tags gebruiken. [/modedit]
Gewijzigd op 01/02/2011 18:32:27 door Bas IJzelendoorn
code] en [/code] tags.
S.v.p. code plaatsen tussen [ wat bedoel je karl?
Dan wordt het hier overzichtelijker.
Als je daar even je code tussen zet kunnen wij het tenminste lezen...
Toevoeging op 01/02/2011 14:05:01:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
$from = "";
if (isset ($_POST['username'])){
$username = preg_replace('#[^A-Za-z0-9]#i', '', $_POST['username']);
$gender = preg_replace('#[^a-z]#i', '', $_POST['gender']);
$b_m = preg_replace('#[^0-9]#i', '', $_POST['birth_month']);
$b_d = preg_replace('#[^0-9]#i', '', $_POST['birth_day']);
$b_y = preg_replace('#[^0-9]#i', '', $_POST['birth_year']);
$email1 = $_POST['email1'];
$email2 = $_POST['email2'];
$pass1 = $_POST['pass1'];
$pass2 = $_POST['pass2'];
$humancheck = $_POST['humancheck'];
$email1 = stripslashes($email1);
$pass1 = stripslashes($pass1);
$email2 = stripslashes($email2);
$pass2 = stripslashes($pass2);
$email1 = strip_tags($email1);
$pass1 = strip_tags($pass1);
$email2 = strip_tags($email2);
$pass2 = strip_tags($pass2);
include_once "xxxxxxx.php";
$emailCHecker = mysql_real_escape_string($email1);
$emailCHecker = str_replace("`", "", $emailCHecker);
$sql_uname_check = mysql_query("SELECT username FROM meetyourpal2 WHERE username='$username'");
$uname_check = mysql_num_rows($sql_uname_check);
$sql_email_check = mysql_query("SELECT email FROM meetyourpal2 WHERE email='$emailCHecker'");
$email_check = mysql_num_rows($sql_email_check);
if ((!$username) || (!$gender) || (!$b_m) || (!$b_d) || (!$b_y) || (!$email1) || (!$email2) || (!$pass1) || (!$pass2)) {
$errorMsg = 'ERROR: You did not submit the following required information:<br /><br />';
if(!$username){
$errorMsg .= ' * User Name<br />';
}
if(!$gender){
$errorMsg .= ' * Gender: Confirm your sex.<br />';
}
if(!$b_m){
$errorMsg .= ' * Birth Month<br />';
}
if(!$b_d){
$errorMsg .= ' * Birth Day<br />';
}
if(!$b_y){
$errorMsg .= ' * Birth year<br />';
}
if(!$email1){
$errorMsg .= ' * Email Address<br />';
}
if(!$email2){
$errorMsg .= ' * Confirm Email Address<br />';
}
if(!$pass1){
$errorMsg .= ' * Login Password<br />';
}
if(!$pass2){
$errorMsg .= ' * Confirm Login Password<br />';
}
} else if ($email1 != $email2) {
$errorMsg = 'ERROR: Your Email fields below do not match<br />';
} else if ($pass1 != $pass2) {
$errorMsg = 'ERROR: Your Password fields below do not match<br />';
} else if ($humancheck != "") {
$errorMsg = 'ERROR: The Human Check field must be cleared to be sure you are human<br />';
} else if (strlen($username) < 4) {
$errorMsg = "<u>ERROR:</u><br />Your User Name is too short. 4 - 20 characters please.<br />";
} else if (strlen($username) > 20) {
$errorMsg = "<u>ERROR:</u><br />Your User Name is too long. 4 - 20 characters please.<br />";
} else if ($uname_check > 0){
$errorMsg = "<u>ERROR:</u><br />Your User Name is already in use inside of our system. Please try another.<br />";
} else if ($email_check > 0){
$errorMsg = "<u>ERROR:</u><br />Your Email address is already in use inside of our system. Please use another.<br />";
} else {
$email1 = mysql_real_escape_string($email1);
$pass1 = mysql_real_escape_string($pass1);
$code = rand(23456789, 99999999);
$pass = md5 ($password);
$full_birthday = "$b_y-$b_m-$b_d";
$ipaddress = getenv('REMOTE_ADDR');
$sql = mysql_query("INSERT INTO meetyourpal2 (username, gender, birthday, email, password, ipaddress, sign_up_date, code)
VALUES('$username','$gender','$full_birthday','$email1','$db_password', '$ipaddress', now())")
or die (mysql_error());
$id = mysql_insert_id();
mkdir("members/$id", 0755);
$to = $email;
$subject = "Activate your account";
$headers = "from: [email protected]";
$server = "mail.50webs.biz";
ini_set("SMTP",$server);
$body = "Hello $username,\n\nYou registered and need to activate your account. Click on the link below or paste it into the url bar of your browser \n\nhttp://mijn domeinnaam.php?code=$code\n\n
Thanks!";
mail($to, $subject, $message, $body, $headers);
die ("You have been registered! Check your email to activate your account<a href='login.php'> Go to Login page</a>");
$msgToUser = "<h2>One Last Step - Activate through Email</h2><h4>$username, there is one last step to verify your email identity:</h4><br />
In a moment you will be sent an Activation link to your email address.<br /><br />
<br />
<strong><font color=\"#990000\">VERY IMPORTANT:</font></strong>
If you check your email with your host providers default email application, there may be issues with seeing the email contents. If this happens to you and you cannot read the message to activate, download the file and open using a text editor.<br /><br />
";
include_once 'msgToUser.php';
exit();
}
} else {
$errorMsg = "";
$username = "";
$gender = "";
$b_m = "";
$b_d = "";
$b_y = "";
$email1 = "";
$email2 = "";
$pass1 = "";
$pass2 = "";
}
?>
$from = "";
if (isset ($_POST['username'])){
$username = preg_replace('#[^A-Za-z0-9]#i', '', $_POST['username']);
$gender = preg_replace('#[^a-z]#i', '', $_POST['gender']);
$b_m = preg_replace('#[^0-9]#i', '', $_POST['birth_month']);
$b_d = preg_replace('#[^0-9]#i', '', $_POST['birth_day']);
$b_y = preg_replace('#[^0-9]#i', '', $_POST['birth_year']);
$email1 = $_POST['email1'];
$email2 = $_POST['email2'];
$pass1 = $_POST['pass1'];
$pass2 = $_POST['pass2'];
$humancheck = $_POST['humancheck'];
$email1 = stripslashes($email1);
$pass1 = stripslashes($pass1);
$email2 = stripslashes($email2);
$pass2 = stripslashes($pass2);
$email1 = strip_tags($email1);
$pass1 = strip_tags($pass1);
$email2 = strip_tags($email2);
$pass2 = strip_tags($pass2);
include_once "xxxxxxx.php";
$emailCHecker = mysql_real_escape_string($email1);
$emailCHecker = str_replace("`", "", $emailCHecker);
$sql_uname_check = mysql_query("SELECT username FROM meetyourpal2 WHERE username='$username'");
$uname_check = mysql_num_rows($sql_uname_check);
$sql_email_check = mysql_query("SELECT email FROM meetyourpal2 WHERE email='$emailCHecker'");
$email_check = mysql_num_rows($sql_email_check);
if ((!$username) || (!$gender) || (!$b_m) || (!$b_d) || (!$b_y) || (!$email1) || (!$email2) || (!$pass1) || (!$pass2)) {
$errorMsg = 'ERROR: You did not submit the following required information:<br /><br />';
if(!$username){
$errorMsg .= ' * User Name<br />';
}
if(!$gender){
$errorMsg .= ' * Gender: Confirm your sex.<br />';
}
if(!$b_m){
$errorMsg .= ' * Birth Month<br />';
}
if(!$b_d){
$errorMsg .= ' * Birth Day<br />';
}
if(!$b_y){
$errorMsg .= ' * Birth year<br />';
}
if(!$email1){
$errorMsg .= ' * Email Address<br />';
}
if(!$email2){
$errorMsg .= ' * Confirm Email Address<br />';
}
if(!$pass1){
$errorMsg .= ' * Login Password<br />';
}
if(!$pass2){
$errorMsg .= ' * Confirm Login Password<br />';
}
} else if ($email1 != $email2) {
$errorMsg = 'ERROR: Your Email fields below do not match<br />';
} else if ($pass1 != $pass2) {
$errorMsg = 'ERROR: Your Password fields below do not match<br />';
} else if ($humancheck != "") {
$errorMsg = 'ERROR: The Human Check field must be cleared to be sure you are human<br />';
} else if (strlen($username) < 4) {
$errorMsg = "<u>ERROR:</u><br />Your User Name is too short. 4 - 20 characters please.<br />";
} else if (strlen($username) > 20) {
$errorMsg = "<u>ERROR:</u><br />Your User Name is too long. 4 - 20 characters please.<br />";
} else if ($uname_check > 0){
$errorMsg = "<u>ERROR:</u><br />Your User Name is already in use inside of our system. Please try another.<br />";
} else if ($email_check > 0){
$errorMsg = "<u>ERROR:</u><br />Your Email address is already in use inside of our system. Please use another.<br />";
} else {
$email1 = mysql_real_escape_string($email1);
$pass1 = mysql_real_escape_string($pass1);
$code = rand(23456789, 99999999);
$pass = md5 ($password);
$full_birthday = "$b_y-$b_m-$b_d";
$ipaddress = getenv('REMOTE_ADDR');
$sql = mysql_query("INSERT INTO meetyourpal2 (username, gender, birthday, email, password, ipaddress, sign_up_date, code)
VALUES('$username','$gender','$full_birthday','$email1','$db_password', '$ipaddress', now())")
or die (mysql_error());
$id = mysql_insert_id();
mkdir("members/$id", 0755);
$to = $email;
$subject = "Activate your account";
$headers = "from: [email protected]";
$server = "mail.50webs.biz";
ini_set("SMTP",$server);
$body = "Hello $username,\n\nYou registered and need to activate your account. Click on the link below or paste it into the url bar of your browser \n\nhttp://mijn domeinnaam.php?code=$code\n\n
Thanks!";
mail($to, $subject, $message, $body, $headers);
die ("You have been registered! Check your email to activate your account<a href='login.php'> Go to Login page</a>");
$msgToUser = "<h2>One Last Step - Activate through Email</h2><h4>$username, there is one last step to verify your email identity:</h4><br />
In a moment you will be sent an Activation link to your email address.<br /><br />
<br />
<strong><font color=\"#990000\">VERY IMPORTANT:</font></strong>
If you check your email with your host providers default email application, there may be issues with seeing the email contents. If this happens to you and you cannot read the message to activate, download the file and open using a text editor.<br /><br />
";
include_once 'msgToUser.php';
exit();
}
} else {
$errorMsg = "";
$username = "";
$gender = "";
$b_m = "";
$b_d = "";
$b_y = "";
$email1 = "";
$email2 = "";
$pass1 = "";
$pass2 = "";
}
?>
Toevoeging op 01/02/2011 14:06:04:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
$getcode = $_GET['code'];
$form = "<form action='xxxx.php' method='post'>
<table>
<tr>
<td>Activate Code:</td>
<td><input type='text' name='code' value='$getcode' size='10'></td>
</tr>
<tr>
<td>Username:</td>
<td><input type='text' name='username'></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='password'></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='submit' value='Activate'</td>
</tr>
</table>
</form>";
if ($_POST['submit']){
$code = strip_tags($_POST['code']);
$username = strip_tags($_POST['username']);
$password = strip_tags($_POST['password']);
if ($code && $username && $password){
if (strlen($code) == 8){
$pass = md5(md5($password));
require ('connect_to_database.php');
$query = mysql_query("SELECT * FROM meetyourpal2 WHERE username='$username' AND password='$pass'");
$numrows = mysql_num_rows($query);
if ($numrows == 1){
$row = mysql_fetch_assoc($query);
$dbcode = $row['code'];
if ($code == $dbcode){
mysql_query("UPDATE meetyourpal2 SET active='1' WHERE activation_code='".mysql_real_escape_string( $_GET['code'])."'");
echo "Your account has been activated. You may now login <a href='login.php'>Click here to login</a>";
}
else
echo "Your activation code was incorrect. $form";
}
else
echo "Your username and password are invalid. $form";
}
else
echo "You have not supplied a valid code. $form";
}
else
echo "You did not fill in the entire form. $form";
}
else
echo "$form";
?>
$getcode = $_GET['code'];
$form = "<form action='xxxx.php' method='post'>
<table>
<tr>
<td>Activate Code:</td>
<td><input type='text' name='code' value='$getcode' size='10'></td>
</tr>
<tr>
<td>Username:</td>
<td><input type='text' name='username'></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='password'></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='submit' value='Activate'</td>
</tr>
</table>
</form>";
if ($_POST['submit']){
$code = strip_tags($_POST['code']);
$username = strip_tags($_POST['username']);
$password = strip_tags($_POST['password']);
if ($code && $username && $password){
if (strlen($code) == 8){
$pass = md5(md5($password));
require ('connect_to_database.php');
$query = mysql_query("SELECT * FROM meetyourpal2 WHERE username='$username' AND password='$pass'");
$numrows = mysql_num_rows($query);
if ($numrows == 1){
$row = mysql_fetch_assoc($query);
$dbcode = $row['code'];
if ($code == $dbcode){
mysql_query("UPDATE meetyourpal2 SET active='1' WHERE activation_code='".mysql_real_escape_string( $_GET['code'])."'");
echo "Your account has been activated. You may now login <a href='login.php'>Click here to login</a>";
}
else
echo "Your activation code was incorrect. $form";
}
else
echo "Your username and password are invalid. $form";
}
else
echo "You have not supplied a valid code. $form";
}
else
echo "You did not fill in the entire form. $form";
}
else
echo "$form";
?>