I'm trying to insert the results of a form into a mysql database.
Here's my condensed form:
--------------------------
----------
----------
---
<body>
<form method="post" action="script.php">
<p><strong>Car</strong></p
>
<label>Year(enter 0000 if unknown):
<select name="year">
<option>0000</option>
<option>1900</option>
</select>
</label>
<p>
<input type="submit" value="Enter Car">
</form>
</body>
Now here's my script.php page:
--------------------------
----------
----------
----------
<?
$DBhost = "xxx";
$DBuser = "xxx";
$DBpass = "xxx";
$DBName = "xxx";
$table = "cars_spotted";
mysql_connect($DBhost,$DBu
ser,$DBpas
s) or die("Unable to connect to database");
@mysql_select_db("$DBName"
) or die("Unable to select database $DBName");
$sqlquery = "INSERT INTO $table VALUES('$_POST[year]','$_P
OST[date_r
ange]','$_
POST[make]
','$_POST[
model]','$
_POST[cond
ition]','$
_POST[stat
e]','$_POS
T[city-cou
nty]','$_P
OST[for_sa
le]')";
$results = mysql_query($sqlquery);
mysql_close();
print "<html><body><center>";
print "<p>You have just entered this record<p>";
print "Year : $year<br>";
print "Date-Range : $date_range<br>";
print "Make : $make<br>";
print "Model : $model<br>";
print "Condition : $condition<br>";
print "State : $state<br>";
print "For-Sale : $for_sale<br>";
print "</body></html>";
?>
I can't get anything to post or to display on the screen. I edited out the connection details.
Start Free Trial