Could someone correct my example so that this dense individual might see the light?
This change to the "$HTTP_POST_VARS", "$_POST" is kicking my...
I have been trying to "insert" into a Mysql database most of the day with no 'success in understanding why' on occassion I succeed. I have reduced this to the least common denominator.
My form "posts". I can prove that by using "print_r($HTTP_POST_VARS)". There is my "post" array.
"Array
[firstname] => Gil
[lastname] =>Conradis
[submit] => submit"
<html>
<head><title>myForm.php</title></head>
<body>
<form method="POST" action="myInsert.php">
<table cellpadding="0" cellspacing="0" width="600">
<tr>
<td width="50%">
First name
</td>
<td width="50%">
<input type="text" name="firstName" size="20">
</td>
</tr>
<tr>
<td width="50%">
Last name
</td>
<td width="50%">
<input type="text" name="lastName" size="20">
</td>
</tr>
<tr>
<td width="50%">
</td>
<td width="50%">
<input type="submit" value="Submit" name="Submit">
</td>
</tr>
</table>
</form>
</body>
</html>
<?php // db.php
DEFINE (DBHOST, "localhost");
DEFINE (DBUSER, "mysql");
DEFINE (DBPASS, "bigbird");
DEFINE (DBNAME, "thisCompany");
// Connect to Mysql:
$db_connection = mysql_connect (DBHOST, DBUSER, DBPASS) or die
('Could not connect to MySQL: ' .
mysql_error());
function dbConnection($db="") {
global $dbhost, $dbuser, $dbpass;
}
//Select the Database:
mysql_select_db (DBNAME) or die
('Could not select the database: ' .
mysql_error());
?>
<?php //myInsert.php
include("db.php");
dbConnection('tblEmployees');
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$sql = "INSERT INTO tblEmployees(employee_firstName, employee_lastName) VALUES ('$firstName','$lastName')";
header("location:/mySuccess.php");
?>
// mySuccess.php
<h1> Done Deal!!! </h1>
Sincerely,
Gil Conradis
😕