well, i know its been a while but i’ve seriously been studying (and trying to have a life…heck, this IS my life :D).
i’ve made a few changes and need a better pair of eyes than mine to see how it looks. well, here goes.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?php
/*** mysql hostname ***/
$hostname = 'xxxx.co';
/*** mysql username ***/
$username = 'xxx';
/*** mysql password ***/
$password = 'xxxx';
try {
<?php
$db = new PDO('mysql:host=localhost;dbname=order001;charset=utf8', 'username', 'password');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$db->setAttribute(PDO::ERRMODE_EXCEPTION);
/*** echo a message saying we have connected ***/
echo 'Connected to database<br />';
catch(PDOException $ex) {
echo "An Error Occurred. The Error Is Being Processed!"; //user friendly message
some_logging_function($ex->getMessage());
?>
<body>
<?php
// define variables and set to empty values
$item = $temple = $quantity = $price = $promotional = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$item = ordertest01($_POST["item"]);
$temple = ordertest01($_POST["temple"]);
$quantity = ordertest01($_POST["quantity"]);
$price = ordertest01($_POST["price"]);
$promotional = ordertest01($_POST["promotional"]);
}
function ordertest01($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<?php
$item = htmlspecialchars($_POST['Item']);
$temple = htmlspecialchars($_POST['Temple']);
$quantity = htmlspecialchars($_POST['Quantity']);
$price = htmlspecialchars($_POST['Price']);
$promotional = htmlspecialchars( $_POST['Promotional']);
$result = $db->exec("INSERT INTO orders0001(Item, Temple, Quantity, Price, Promotional) VAULES (':item', ':temple',
':quantity', ':price', ':promotional')";
$stmt->bindParam(':item', $item);
$stmt->bindParam(':temple', $temple);
$stmt->bindParam(':quantity', $quantity);
$stmt->bindParam(':price', $price);
$stmt->bindParam(':promotional', $promotional);
header( "Location: http://www..com/.....html" )
/*** close the database connection ***/
$dbh = null;
?>
</body>
</html>
any feedback is most welcomed. thanks