-
Notifications
You must be signed in to change notification settings - Fork 0
/
log1.php
87 lines (61 loc) · 2.03 KB
/
log1.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
86
87
<?php
ob_start();
$servername = "localhost";
$username = "root";
$password = "";
//$conn = new PDO("mysql:host=$servername;dbname=face", $username, $password);
// $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// collect value of input field
$fname = $_POST['notes'];
try {
$conn = new PDO("mysql:host=$servername;dbname=face", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//$sql = "INSERT INTO MyGuests (firstname, lastname, email)
//VALUES ('John', 'Doe', '[email protected]')";
// use exec() because no results are returned
//$conn->exec($sql);
$myfile = fopen("id.txt", "r") or die("Unable to open file!");
$iddd=fgets($myfile);
fclose($myfile);
$iddd+=1;
$myfile = fopen("id.txt", "w") or die("Unable to open file!");
fwrite($myfile, $iddd);
fclose($myfile);
$myfile = fopen("mob.txt", "r") or die("Unable to open file!");
$mob=fgets($myfile);
fclose($myfile);
$stmt = $conn->prepare("INSERT INTO data(id,NOTES,MOBILENUMBER) VALUES (:firstname,:surname,:mobilenumber)");
$stmt->bindParam("firstname", $iddd,PDO::PARAM_INT) ;
$stmt->bindParam("surname", $fname,PDO::PARAM_STR) ;
$stmt->bindParam("mobilenumber", $mob,PDO::PARAM_STR) ;
$stmt->execute();
}
catch(PDOException $e)
{
echo $stmt . "<br>" . $e->getMessage();
}
}
header("Location: log.php");
ob_end_flush();
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="5.css">
</head>
<body>
<script type="text/javascript">
<!--
function Redirect() {
window.history.back();
location.reload();
}
//-->
</script>
<div class="cover">
<div class="tx">YOUR NOTES HAS BEEN CREATED!!!YOU CAN NOW LOGIN AND SEE YOUR NOTES WHICH WILL BE SAVED BY US AND IS SAFE.</div>
<div class="tx1"><input type="submit" name="tf" value="YEP!!!" onclick="Redirect();"></div>
</body>
</html>