Ok, i am so new to PHP and today, i wanted to create a very simple php code that submits username and country name into myqsl. So, I created databse and tables in phpMyAddmin, and i created two php files ( c below ) i.e. form.php & insert.php
This is form.php
<?php
mysql_connect("localhost", "root", "test") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("testdb") or die(mysql_error());
?>
<?php
@$username = $_POST['name'];
@$country = $_POST['country'];
?>
<form action="insert.php" method="post" >
username<input type="text" name="name" value=""> </br>
country<input type="text" name="country" value=""></br>
<input type="submit" name="submit" value="Submit">
</form>
This is insert.php
<?php
//
//echo $username;
//echo $country;
?>
<?php
include ('forum.php');
if (isset($_REQUEST['Submit'])) {
mysql_query("INSERT INTO users
(name, country) VALUES('$username', '$country' ) ")
or die(mysql_error());
}
?>
I know, this might be the funniest code you've ever seen, but i am puzzled.
What is it, that i have done wrong in here?