forked from ishaangurnani/Chef2Door
-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.php
34 lines (30 loc) · 1.03 KB
/
database.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
if(isset($_POST['submit'])) {
$email = $_POST['email'];
$password = $_POST['password'];
$phone = $_POST['phone'];
$dob = $_POST['dob'];
$age = $_POST['age'];
}
$servername = "localhost";
$conn = new PDO("mysql:host=$servername;dbname=chef2door", 'root', '');
// Inserting values into the table using prepared statement
try {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->beginTransaction();
$conn->exec("INSERT INTO profile (email, pwd, phone, dob, age)
VALUES ('$email', '$password', '$phone', '$dob', '$age')");
$conn->commit();
echo "<br>New records added successfully";
} catch(PDOException $e) {
$conn->rollback();
echo "<br>Error in inserting values in the created table.<br>" . $e->getMessage();
}
// echo "</table>";
// echo "<br><form action = 'update.php' method = 'post'><br>
// <button name='display'>Display Details</button><br><br>
// <button name='update'>Update Values</button><br><br>
// </form>";
header('Location: login.html');
$conn = null;
?>