briintex1
06-01-2004, 07:16 PM
I was wondering where I might have gone wrong on adding information to a database, the country_id is an autonumber, so I don't have to add it. But when a user puts in a name of the country, it adds it to the database, once they click the submit button, and it returns them back to this page. It passes the variable through the url I think but I am not for sure about that one either? But any suggestions are helpful...
<?php
$db = mysql_connect("localhost", "tableName", "PW")or die(mysql_error());
mysql_select_db("database")or die(mysql_error());
$obj = mysql_query("SELECT * FROM country");
$obj=mysql_fetch_array($obj);
INSERT INTO COUNTRY (country_id, country_name) VALUES($country) ?>
}
echo '</select>';
}
?>
<html>
<head
</head>
<title><? echo $obj[1] ?></title>
<FORM ACTION="index.php" METHOD=POST>
Please enter the name of the country to put into the database.
<p>TITLE:<INPUT TYPE="text" NAME="country" SIZE=25 MAXLENGTH=25>
<p><INPUT TYPE="submit">
</FORM>
<?php echo $country ?>
<body>
</body>
</html>
<?php
$db = mysql_connect("localhost", "tableName", "PW")or die(mysql_error());
mysql_select_db("database")or die(mysql_error());
$obj = mysql_query("SELECT * FROM country");
$obj=mysql_fetch_array($obj);
INSERT INTO COUNTRY (country_id, country_name) VALUES($country) ?>
}
echo '</select>';
}
?>
<html>
<head
</head>
<title><? echo $obj[1] ?></title>
<FORM ACTION="index.php" METHOD=POST>
Please enter the name of the country to put into the database.
<p>TITLE:<INPUT TYPE="text" NAME="country" SIZE=25 MAXLENGTH=25>
<p><INPUT TYPE="submit">
</FORM>
<?php echo $country ?>
<body>
</body>
</html>