/
emailconfirm.php
72 lines (57 loc) · 1.65 KB
/
emailconfirm.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
<html>
<head>
<title>Email confirmation tutorial</title>
</head>
<body>
<?php
include 'core/init.php';
$username = $_GET['username'];
$code = $_GET['code'];
$db_code = confirmcode_from_username($username);
if($code == $db_code)
{
activateUser($username);
echo "Thank you. Your email has been confirmed";
}
else
{
echo "Username and code don't match";
}
/* /////////////////////////////////////////////////////////////////////
$username = $_GET['username'];
$code = $_GET['code'];
$query = "SELECT * FROM users WHERE username = '".$username."'";
$queryResults = mysql_query($query);
//echo "<p>query results = $queryResults</p>";//testing
$numRows = mysql_num_rows($queryResults);
// echo "<p>".$numRows."</p>";//testing
for($iter = 0; $iter < $numRows; $iter++)
{
$row = mysql_fetch_assoc($queryResults);
$rowData = $row['confirmcode'];
// echo "<p>iter = ".$iter." | data = ".$rowData."</p>";//testing
if( isset($rowData) && !empty($rowData) )
{
$db_code = $rowData;
}
}//eofl
// while($row = mysql_fetch_assoc($queryResults))
// {
// $db_code = $row['confirmcode'];
// }
// echo "<p> code = ".$code." | db code =".$db_code."</p>";//testing
if($code == $db_code)
{
$queryResults1 = mysql_query("UPDATE users SET confirmed ='1' ");
$queryResults2 = mysql_query("UPDATE users SET confirmcode ='0' ");
// echo "<p>1 query result = ".$queryResults1."</p>";//testing
// echo "<p>2 query result = ".$queryResults2."</p>";//testing
echo "Thank you. Your email has been confirmed";
}
else
{
echo "Username and code don't match";
} */
?>
</body>
</html>