-
Notifications
You must be signed in to change notification settings - Fork 3
/
changepw1.php
53 lines (36 loc) · 1019 Bytes
/
changepw1.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
<?php
$username = $_POST['username'];
function md5_salt($string) {
$salt = md5($string."%*4!#$;\.k~'(_@");
// Hash the string
$string = md5("$salt$string$salt");
return $string; }
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("irkut", $con);
$npassword = $_POST['npassword'];
$newpass=md5_salt($npassword);
$query = "SELECT password FROM validate ".
"WHERE username = \"$username\" ";
$result = mysql_query($query, $con);
while($row = mysql_fetch_array($result))
{
$password = $row[password];
}
mysql_close($con);
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("irkut", $con);
mysql_query("UPDATE validate SET password = '".$newpass."'
WHERE username = '".$username."' ");
mysql_close($con);
header ("Location: login2.php?username=$username & password=$npassword");
//echo $opassword;
//echo $npassword;
?>