PHP MYSQL

SIMPLE RESERVATION FORM WITH PHP MYSQL

(quick guide & example)

RESERVATION TABLE

01

id date name email tel

INTEGER | PRIMARY KEY DATE VARCHAR(255) VARCHAR(255) VARCHAR(60)

RESERVATION FORM

02

<form method="post" >   <input type="text" name="name">   <input type="email" name="email">   <input type="text" name="tel" >   <input type="date" name="date">   <input type="submit" value="GO!"> </form>

PHP SAVE RESERVATION

03

CONNECT TO DATABASE $pdo = new PDO("mysql:host=HOST; dbname=NAME;charset=utf8", USER, PASSWORD);

INSERT INTO DATABASE $stmt = $pdo->prepare("INSERT INTO `reservations`  (`date`, `name`, `email`, `tel`) VALUES (?,?,?,?)"); $stmt->execute([   $_POST["date"], $_POST["name"],   $_POST["email"], $_POST["tel"] ]);