PHP MYSQL

SIMPLE RESERVATION FORM WITH PHP MYSQL

RESERVATION TABLE

01

id date name email tel

INT(11) PRIMARY KEY DATE VARCHAR(255) VARCHAR(255) VARCHAR(60)

<form method="post"              action="RESERVE.PHP">   <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>

RESERVATION FORM

02

PHP SAVE RESERVATION (A)

03

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

PHP SAVE RESERVATION (B)

04

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