-
Notifications
You must be signed in to change notification settings - Fork 0
/
forgot_id.php
34 lines (28 loc) · 857 Bytes
/
forgot_id.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
<?php
try{
ini_set( "display_errors", 0);
session_destroy();
include 'db_init.php';
include 'forgot_id.html';
$link=new mysqli('localhost','root','','councelling');
if($link->connect_error)
throw new Exception("Connection Error.");
$email=$_POST["email"];
//print_r($email);
$stmt=$link->prepare("select username from student where mail=?");
$stmt->bind_param("s", $email);
$stmt->execute();
$result=$stmt->get_result();
$out=$result->fetch_array();
//print_r($out);
$username=$out["username"];
if(!$username==""){
echo "<script>document.getElementById('mail').value=' ".$email."';document.getElementById('id').value=' ".$username."';</script>";
//$_POST["username"]=$username;
}
else
throw new Exception("Invalid E-mail.");
} catch (Exception $ex) {
echo '<script>alert("'.$ex->getMessage().'")</script>';
}
?>