-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcusSubmit.php
More file actions
42 lines (31 loc) · 885 Bytes
/
cusSubmit.php
File metadata and controls
42 lines (31 loc) · 885 Bytes
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
<!DOCTYPE html>
<html>
<body>
<?php
// data from form being stored in variable
$firstName = $_POST["fn"];
$lastName = $_POST["ln"];
$email = $_POST["em"];
$address = $_POST["ad"];
$con = mysqli_connect("localhost", "root", "", "CIS224_php");
if(!$con)
{
die("Connection unsuccessful: " . mysql_error());
// stops the program if the connection is unsuccessful and displays the error message.
}
$sql = "INSERT INTO customers (FirstName, LastName, Email, Address)
VALUES('$firstName', '$lastName', '$email', '$address')";
if(mysqli_query($con, $sql)) // function that runs the query. Needs the two arguments.
{
echo "System updated!";
}
else
{
echo "Error!" . mysqli_error($con);
}
mysqli_close($con); // close connect
?>
<a href="cusForm.php">Go back to form</a>
<br />
</body>
</html>