-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstoreContactInfo.php
More file actions
40 lines (32 loc) · 1.07 KB
/
storeContactInfo.php
File metadata and controls
40 lines (32 loc) · 1.07 KB
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
<?php
session_start();
$dbconnect = mysqli_connect("127.0.0.1", "root", "", "globalviews");
$name = filter_input(INPUT_POST, 'name');
$address = filter_input(INPUT_POST, 'address');
$phone = filter_input(INPUT_POST, 'phone');
$email = filter_input(INPUT_POST, 'email');
$pin = "B";
//Assign random pin to new sales representative
$i = 0; $digits = 5;
while($i < $digits)
{
//generate a random number between 0 and 9.
$pin .= mt_rand(1, 9);
$i++;
}
// Check connection
if ($dbconnect->connect_error)
{
die("Connection failed: " . $dbconnect->connect_error);
}
$sql = "INSERT INTO potential_buyer (buyer_no, name, address, phone, email)
VALUES ('$pin', '$name', '$address', '$phone', '$email')";
if ($dbconnect->query($sql) === TRUE)
{
echo "<script>alert('Thank you!'); window.location.href='index.html';</script>";
} else
{
echo "<script>alert('You already filled one'); window.location.href='contactUs.html';</script>";
}
$dbconnect->close();
?>