Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 473
0 Users 2 Guests Online
Forum Index » PHP + MySQL » Pincode
Posted on Wednesday 30th May 2007 at 07:41 PM
MCP
templates/default/images/noavatar.png's Avatar
Junior Member
Is there any way that the user may know their pincode without me using mySQL and PMing it to them? Cause the only way they can retrieve forgotten passwords is for them to identify themselves with username and pincode.
Posted on Wednesday 30th May 2007 at 08:41 PM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
Add it to the register.php ill whip up a code now and post it.
Posted on Wednesday 30th May 2007 at 08:45 PM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
PHP Code
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
<?php
session_start
(); //allows session
include "config.php";
echo 
"<center>";
//checks if there trying to veriy there account
if(isset($_GET['verify'])){
//gets the code and makes it safe
$code addslashes($_GET['code']);
//gets the code from the database
$getcode=mysql_query("SELECT * FROM `verification` WHERE `code` = '$code'");
//counts the number of rows
$getcode mysql_num_rows($getcode);
//if the ammount of rows is 0 the code does not exist
if ($getcode == 0

echo 
"Invalid verification code!"

//or if the code does exist we will activiate there account
else
{
//get the data from the database
$getcode=mysql_query("SELECT * FROM `verification` WHERE `code` = '$code'");
//fetchs the data from the db
$dat mysql_fetch_array($getcode);
//sets the users user level to 2 which means they can now use there account
$update mysql_query("UPDATE `members` SET `userlevel` = '2' WHERE `username` = '".$dat['username']."'") or die(mysql_error());
//deletes the code as there is no use of it now
$delete mysql_query("DELETE FROM `verification` WHERE code = '$code'");
//says thanks and your account is ready for use
echo "Thank you, Your account has been verified.";
}
}
else
//if we have posted the register for we will register this user
if(isset($_GET['register'])){
//check to see if any fields were left blank
if((!$_POST[username]) || (!$_POST[password]) || (!$_POST[cpassword]) || (!$_POST[email])|| (!$_POST[pincode])){
echo 
"A field was left blank please go back and try again.";
}
else
{
//posts all the data from the register form
$username $_POST[username]; 
$password $_POST[password]; 
$cpassword $_POST[cpassword]; 
$email $_POST[email];
$pincode $_POST[pincode];
//check see if the 2 passwords are the same
if($password == $cpassword)
{
//encrypts the password 8 times
$password sha1(md5(md5(sha1(md5(sha1(sha1(md5($password)))))))); 
$cname mysql_query("SELECT `username` FROM `members` WHERE `username` = '$username'"); 
$cnamemysql_num_rows($cname); 
//checks to see if the username or email allready exist
if ($cname>=1) { 
echo 
"The username is already in use"
}
else
{
//gets rid of bad stuff from there username and email
$username addslashes(htmlspecialchars($username)); 
$email addslashes(htmlspecialchars($email));
$pincode addslashes(htmlspecialchars($pincode));
//adds them to the db
$adduser mysql_query("INSERT INTO `members` (`username`, `password`, `email`, `pincode`) VALUES('$username','$password','$email','$pincode')");
//posible letters for the verification code
$alphanum  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
//shuffles the letters around to create a 16 long code
$code substr(str_shuffle($alphanum), 016); 
//adds there code along with there user name to the db
$addcode mysql_query("INSERT INTO `verification` (`username`, `code`) VALUES('$username','$code')");
//don't edit this, this is the link for there activication
$link "http://$host$self?verify&code=$code";
//sends the email to the person
mail("$email""Member-Ship Validation""Thank you for registering on $sitename.
Please copy the below link into you address bar,

$link""From: Site Verification");
//message sent now lets tell them to check there email
echo "You are now registered,<br><br>Please check your email to activate your account.";
}
}
else
{
echo 
"Your password and conformation password do not match!";
}
}
}
else
{
//none of the above so lets show the register form
echo "<form action='register.php?register' method='post'>
<fieldset style='width: 350'>
<table width='350'>
  <tr>
    <td width='150'>Username:</td>
    <td width='200'><input type='text' name='username' size='30' maxlength='25'></td>
  </tr>
  <tr>
    <td>Password:</td>
    <td><input type='password' name='password' size='30' maxlength='25'></td>
  </tr>
  <tr>
    <td>Confirm Password:</td>
    <td><input type='password' name='cpassword' size='30' maxlength='25'></td>
  </tr>
  <tr>
    <td>Email:</td>
    <td><input type='text' name='email' size='30' maxlength='55'></td>
  </tr>
  <tr>
    <tr>
    <td>Pincode:</td>
    <td><input type='text' name='pincode' size='30' maxlength='4'></td>
  </tr>
  <tr>
    <td colspan='2'><center><input type='submit' value='Register'></center></td>
  </tr>
</table>
</fieldset>
</form>"
;
}
echo 
"<center>";
?

Try that, not tested so post error if you get.
Posted on Wednesday 30th May 2007 at 09:18 PM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
By pincode he means your Forgot Password tutorial. I suppose.

This will do the trick:

PHP Code
1
2
3
4
5
6
<?php
include('config.php');
$getpin mysql_query("GET pincode FROM members WHERE username = '$_POST[username]'");

echo 
"Your Pincode is $getpin";
?>


Not tested, try it and reply to see if it works.
Posted on Wednesday 30th May 2007 at 09:22 PM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
@Diablosblizz it would be.

PHP Code
1
2
3
4
5
6
7
8
<?php
include('config.php');
$fetch mysql_query("SELECT * FROM `members` where username = '$logged[username]');
$getpin = mysql_fetch_array($fetch);

echo "
Your Pincode is $getpin[pincode]";
?>
Posted on Wednesday 30th May 2007 at 09:22 PM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
@Diablosblizz it would be.

PHP Code
1
2
3
4
5
6
7
8
<?php
include('config.php');
$fetch mysql_query("SELECT * FROM `members` where username = '$logged[username]');
$getpin = mysql_fetch_array($fetch);

echo "
Your Pincode is $getpin[pincode]";
?>
Posted on Wednesday 30th May 2007 at 09:24 PM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
I don't see why you even need to fetch the array. Mysql should automatically do that, but, it doesn't.

That code will work above.
Posted on Wednesday 30th May 2007 at 10:18 PM
MCP
templates/default/images/noavatar.png's Avatar
Junior Member
I have got it working. Thanks for the help.
Posted on Thursday 31st May 2007 at 08:14 AM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
Its k its what were here for.
Posted on Friday 22nd June 2007 at 04:44 PM
Dean
templates/default/images/noavatar.png's Avatar
Active Member
Topic Solved

- Locked -