Hi,

I've made a script where I want the results of an order form to be inserted
into a MySQL database. Connecting to the database goed fine (tested it) but
my check if the values are inserted into the database gives the error
message I created "Problem, the information cannot be recorded". I hope
someone can spot the error in the script.

Please see the script below, I faked server address and user/pass and stuff.
Here a customer enters his name and address, after already selecting to buy
a new car (BMW). This is just an example.

<html>
<head>
<title>Form input & processor</title>
</head>
<body>

<?
if(!IsSet($stage))
 {
?>

<p>Please fill in the form below</p>

<form method="post" action="<? print("$PHP_SELF"); ?>">
<table><tr>
<tr><td>Last name:</td> <td><input type="text" name="lname"
size="30"></td></tr>
<tr><td>First name: <td><input type="text" name="fname" size="20"></td></tr>
<tr><td>Street: <td><input type="text" name="street" size="50"></td></tr>
<tr><td>Number: <td><input type="int" name="number" size="4"></td></tr>
<tr><td>Car: <td><input type="text" name="car" size="20"
value="BMW"></td></tr>
<input type="hidden" name="stage" value="1">
<tr><td><input type="submit"></td></tr>
</form>

<?
 }
else
 {

/* connecting to database */
mysql_connect("address.myserver.com", "myusername", "mypassword") or
die("Problem, can't connect to database");
mysql_select_db("databasename");

/* insert values to database */
$query = "INSERT INTO tablename (lname, fname, street, number, car) VALUES
('$lname', '$fname' '$street', '$number', '$car')";
$result = mysql_query($query);
if($result == 0)
 print("Problem, the information cannot be recorded");

else
 print("You have succesfully placed an order for a car");
 }
?>

</body>
</html>


-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to