First of all, please take a more object orientated approach to your coding. You've included the database connect function in with the page code. This is an unsecure way of connecting and paves the way for heaps of redundant code in your application.
Create a php file called "db_conn.php" and place all db info in it. Save it in a folder which resides out of the public http directory.
e.g.
../../db_conn.php
PHP Code:
<?php
$host = "localhost";
$db = "joesauto";
$user = "joeuser";
$pass = "joepass";
$dbConn = mysql_pconnect($host, $user, $pass) or trigger_error(mysql_error(),E_USER_ERROR);
?>
When you script a php page that requires a connection to the database, include the file at the beginning of the page script.
e.g.
PHP Code:
<?php
include('../../db_conn.php');
?>
Your connection to the database within the script is then simplified to a single line of code.
e.g. Database connection
PHP Code:
<?php
mysql_select_db($db, $dbConn);
?>
Its also good coding practice to not rely on global vars being registered as being ON. So convert your long POST values to short before you use them.
e.g.
PHP Code:
<?php
if(isset($_POST['submit'])){
$year = $_POST['year'];
$make = $_POST['make'];
// etc
}
?>
Your form processing script can also be much simpler.
e.g. At the top of the page, under the include, write the form processing.
PHP Code:
<?php
if(isset($_POST['submit'])){
// long to short
$year = $_POST['year'];
$make = $_POST['make'];
$model = $_POST['model'];
$price = $_POST['price'];
// etc
// do insert
$sql = 'INSERT INTO joesauto (year,make,model,price) '.
"VALUES ('" . $year . "',"."'" . $make . "','" . $model . "','" . $price . "')";
mysql_select_db($db, $dbConn);
$result = mysql_query($sql, $dbConn) or die(mysql_error());
//redirect user to page after successful record insert
$successfulRedirectURL = 'success.php';
header('Location: ' . $successfulRedirectURL);
exit();
}
?>
As far as what url to submit the form to, a simple <form name="formName" method="POST" action="#"> will suffice if the processing code is on the same page. Hope this helps a bit..