OK, I have been banging my head against this for 2 days. I am new to PHP so please bear with me. I just want to have a user enter 5 fields in a form and post it to my db. I can already search the db and display the data that exists in the db. no problems there, so I know my connection string info is working.
But, whatever I try to do to enter the data in isn't working. here is my latest version of code:
<html>
<body>
<?php
if ($submit) {
// process form
$db = mysql_connect("XXXX", "XXXX", "XXXX");
//connect to the db
mysql_select_db("mydbname",$db)or die("Could not select the database '" . $db . "'. Are you sure it exists?");
//try to get the data from the URL
$SERVER['QUERY_STRING']; //possibly unneeded if $get does what it should
$country = ($GET['country']);
$state = ($GET['state']);
$city = ($GET['city']);
$user = ($GET['user']);
$email = ($_GET['email']);
$sql = "INSERT INTO users (country,state,city,user,email) VALUES ('$country','$state','$city','$user','$email')";
$result = mysql_query($sql) or die("Query failed");
echo "Thank you! Information entered.\n";
} else{
// display form
?>
<form method="retrieve" action="<?php echo $PHP_SELF?>">
Country:<input type="Text" name="Country"><br>
State:<input type="Text" name="State"><br>
City:<input type="Text" name="City"><br>
Name:<input type="Text" name="user"><br>
E-Mail Address:<input type="Text" name="email"><br>
<input type="Submit" name="submit" value="Enter information">
</form>
<?php
} // end if
?>
</body>
</html>
So, please tell me why no data gets put into my DB. I am about to scream.
Thanks!
-Tony
SSG Anthony Damata - HHB 197th FA BDE