forked from ivannovak/jpmaster77-s-Login-System-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalid.php
executable file
·86 lines (73 loc) · 2.5 KB
/
valid.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
<?php
/**
* You can gather additional details by following
* the tutorial posted at:
*
* http://ivannovak.com/email-account-activation/
*
* Author: Ivan Novak
* Last Updated: August 2, 2009 by Ivan Novak
*/
include("include/session.php");
global $database;
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Jpmaster77's Login Script</title>
<link rel="stylesheet" href="-css/960/reset.css" type="text/css" />
<link rel="stylesheet" href="-css/960/960.css" type="text/css" />
<link rel="stylesheet" href="-css/960/text.css" type="text/css" />
<link rel="stylesheet" href="-css/style.css" type="text/css" />
</head>
<body>
<div id="main" class="container_12">
<?php
/*
* If the someone accesses this page without the correct variables
* passed, assume they are want to fill out a form asking for a
* confirmation email.
*/
if(!(isset($_GET['qs1']) && isset($_GET['qs2']))){
?>
<div id="email">
<h1>Send Confirmation Email</h1>
<form action="process.php" method="POST">
<p>Username: <input type="text" name="user" maxlength="30" value="<?php echo $form->value("user"); ?>"><?php echo $form->error("user"); ?></p>
<p>Password: <input type="password" name="pass" maxlength="30" value="<?php echo $form->value("pass"); ?>"><?php echo $form->error("pass"); ?></p>
<p><input type="hidden" name="subConfirm" value="1"><input type="submit" value="Send!"></p>
<p><a href="main.php">Back to Main</a></p>
</form> </div>
<?php
}
/* If the correct variables are passed, define and check them. */
else{
$v_username = $_GET['qs1'];
$v_userid = $_GET['qs2'];
$field = 'valid';
$q = "SELECT userid from ".TBL_USERS." WHERE username='$v_username'";
$query = $database->query($q) or die(mysql_error());
$query = mysql_fetch_array($query);
/*
* if the userid associated with the passed username does not
* exactly equal the passed userid automatically redirect
* them to the main page.
*/
if(!($query['userid'] == $v_userid)){
echo "confirmation failed, username and UIN do not match";
}
/*
* If the userid's match go ahead and change the value in
* the valid field to 1, display a 'success' message, and
* redirect to main.php.
*/
else{
$database->updateUserField($v_username, $field, '1') or die(mysql_error());
echo $v_username."'s account has been successfully verified. You can now <a href='main.php'>login</a>.";
}
}
?>
</div>
</body>
</html>