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"    required/>   <input type="email" name="email"   required/>   <input type="text" name="tel"    required/>   <input type="date" name="date"    min="<?=date("Y-m-d")?>" required/>   <input type="submit" value="GO!"/> </form>

RESERVATION FORM

02

PHP SAVE RESERVATION

03

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

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