PHP MYSQL HTML

SIMPLE ORDER FORM WITH PHP MYSQL

ORDER DATABASE TABLE

01

order_id name email qty

INT(11) PRIMARY KEY VARCHAR(255) VARCHAR(255) INT(5)

<form method="post" target="_self">    <input type="text" name="name"/>    <input type="email" name="email"/>    <input type="number" name="qty""/>   <input type="submit" value="GO!"/>  </form>

HTML ORDER FORM

02

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

PHP SAVE ORDER (A)

03

PHP SAVE ORDER (B)

04

PREPARE SQL $stmt = $pdo->prepare("   INSERT INTO `orders`    (`name`, `email`, `qty`)   VALUES (?,?,?) ");

PHP SAVE ORDER (C)

05

SAVE SUBMITTED FORM $stmt->execute([   $_POST["name"],   $_POST["email"],    $_POST["qty"]  ]);