Running PHP 5 and while attempting to work with database MYSQL I get this error.
"Bad Request (Invalid URL)", the url that shows is http://192.168.1.249:8080/tests/<?=$_SERVER['PHP_SELF']?>" and I am running ISS6, global is off, and below is the code:
<?php
if (!isset($_POST['submit'])) {
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
Country: <input type="text" name="country">
National animal: <input type="text" name="animal">
<input type="submit" name="submit">
</form>
<?php
}
else {
$host = "localhost";
$user = "----";
$pass = "----";
$db = "testdb";
$country = empty($_POST['country']) ? die ("ERROR: Enter a country") : mysql_escape_string($_POST['country']);
$animal = empty($_POST['animal']) ? die ("ERROR: Enter an animal") : mysql_escape_string($_POST['animal']);
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
mysql_select_db($db) or die ("Unable to select database!");
$query = "INSERT INTO symbols (country, animal) VALUES ('$country', '$animal')";
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
echo "New record inserted with ID ".mysql_insert_id();
mysql_close($connection);
}
?>
Any help would be appreciated.