forked from sydneykleingartner/pearlhacks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform.php
25 lines (22 loc) · 735 Bytes
/
form.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
<?php
$servername = "192.168.64.2";
$username = "root";
$password = "password";
$dbname = "pearlhacks";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = $conn->prepare("INSERT INTO user (fname, lname, email) VALUES (:firstname, :lastname, :email)");
$sql->bindParam(":firstname", $_POST['firstname']);
$sql->bindParam(":lastname", $_POST['lastname']);
$sql->bindParam(":email", $_POST['email']);
$sql->execute();
echo "New record created successfully";
}
catch(PDOException $e)
{
echo "ERROR: ". $e->getMessage();
}
$conn = null;
?>