-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewPass.php
37 lines (29 loc) · 1018 Bytes
/
newPass.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
<?php
session_start();
$email =$_SESSION['formdata'];
$password = $_POST['psw'];
$passworR = $_POST['psw-repeat'];
if($passworR!=$password){
echo "<h1>Passwords Dont Match</h1>";
session_start();
$_SESSION['formdata'] = $email; //or whatever
header('Location: editInfo.php');
}else{
$username="";
$password="";
$conn= new mysqli("localhost",$username,$password,"tracker");
if($conn->connect_error){
die("Failed to connect: ".$con->connect_error);
}else{
// $holder = date("Y-m-d");
// echo $holder;
$passwordSHA = hash('sha256',$password);
$stmt = $conn->prepare("update login set pass = ? where email=?;"); //prevent sql injection
$stmt->bind_param("ss",$passwordSHA,$email);
$stmt->execute();
session_start();
$_SESSION['formdata'] = $email; //or whatever
header('Location: main.php');
}
}
?>