Source Code of simpleInsertExample.php


<?php
//IGNORE THIS
//WILL DISPLAY CODE OF THIS FILE ON THE WEBPAGE//
######################################################################
echo "<h2><br>Source Code of ".basename((string)__FILE__) . "</h2><hr>";
show_source(__FILE__);die();
#######################################################################



require("database.php");

//Assume you have the following information available, either by form submission or another source
$_POST['firstName'] = "Jack";
$_POST['lastName'] = "Black";

//DO AN INSERT INTO THE DATABASE
// assuming we are using the "wcss_learning" database as defined for the learning-project
$query $pdo->prepate("INSERT INTO customers(cust_fname,cust_lname) VALUES(:fname,:lname)");
$query->execute(array(
    
"fname" => $_POST['firstName'],
    
"lname" => $_POST['lastName']
    ));

?>