Huggies12345
2011-12-04 17:47:59 UTC
I have two html made text boxes one that is called "name" and another that is called "regnum". I also have a submit button.
They are both used to add data to a database.
The name text box should add a name to the database under the "name" heading and the regnum should add a number under the "regnum" heading
Here is the code for them:
HTML Code:
Here is the PHP code that i am using for adding the user to the database:
PHP Code:
$host="localhost";
$username="root";
$password="";
$database="lab2";
mysql_connect("$host", "$username", "$password") or die(mysql_error());
mysql_select_db("$database") or die(mysql_error());
$name = $_POST['name'];
$regnum = $_POST['regnum'];
if(!$_POST['submit2']){
echo "Enter A Vaue";
}else{
mysql_query("INSERT INTO lab2('name', 'regnum')
VALUES(NULL, '$name', '$regnum')") or die(mysql_error());
echo "User Added To Database";
}
The problem i get with this is "Undefined Index name and regnum".
I watched a video on youtube and this is how the guy did it but it worked for him and for some reason it doesn't work for me.
Can anyone help??
Thanks.