Hi, here's my form.html file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<form action="welcome.php" method="post">
Number: <input type="text" name="number" />
Name: <input type="text" name="name" />
Surname: <input type="text" name="surname" />
Level: <input type="text" name="level" />
<input type="submit" />
</form>
</body>
</html>And here's my welcome.php file. I get 4 such errors in line 28:
Notice: Undefined index: number in C:\wamp\www\PhpProject1\welcome.php on line 28. I have coded everything exactly like in this link
PHP MySQL Insert Into. Does anyone know what's wrong?
<html>
<body>
<!--Welcome <?php echo $_POST["fname"]; ?>!<br />
You are <?php echo $_POST["age"]; ?> years olddd2.-->
<?php
$con = mysql_connect("localhost","root","");
if (!$con){
die('<br/> Could not connect: ' . mysql_error());
} else{
echo "<br/> Conected";
mysql_select_db("base1", $con);
$query = "CREATE TABLE Players (
Number int NOT NULL,
PRIMARY KEY (Number),
FirstName char(20),
LastName char(20),
Level int
)";
if (mysql_query($query, $con))
echo "<br/> table created";
else
echo "<br/> Error: " . mysql_error();
$query = "INSERT INTO Players (Number, FirstName, LastName, Level) VALUES ('$_POST[number]', '$_POST[name]', '$_POST[surname]', '$_POST[level]')";
if (mysql_query($query, $con))
echo "<br/> inserted";
else
echo "<br/> Error: " . mysql_error();
$query = "DROP TABLE Players";
if (mysql_query($query, $con))
echo "<br/> table deleted";
else
echo "<br/> Error: " . mysql_error();
}
mysql_close($con);
?>
</body>
</html>