I've just started learning php (again! lol) and am trying a few simple things out...
I've 2 pages. The first ("names1.php) is a form for a user to input info.. this is then sent to the second page where the info is displayed and the mysql database updated.
However.. I can't seem to find the right way of defining the variables.. keep getting "Variables undefined..etc" error messages.
It's probably an incredibly simple error.. but as a newbie in this I'm in need of an expert pair of eyes to find it!
Thanks in advance
Luds
"names1.php"
<html>
<head>
<title>names</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
echo "Please enter the following information.
<form action='processform.php' method='post'>\n
<input type='text' name='firstName'>\n
<input type='text' name='lastName'>\n
<input type='text' name='address' size='30'>\n
<input type='text' name='email'>\n
<input type='submit' value='Go to next page'>\n
</form>\n";
?>
</body>
</html>
"processform.php"
<html>
<head>
</head>
<body>
<h2>You have just entered this information</h2>
<?php
$user="luds";
$host="localhost";
$password="";
$database="invester_names";
$connection = mysql_connect($host,$user,$password) or die
("Couldn't connect to server!"
$db = mysql_select_db($database,$connection) or die ("Couldn't select database"
foreach ($HTTP_POST_VARS as $key => $value)
{
echo "$key- $value<br>";
}
$query = "INSERT INTO personal (firstName,lastName,address,email)
VALUES ('$firstName','$lastName','$address','$email')";
$result = mysql_query($query) or die ("Couldn't execute query."
echo "Database Updated";
?>
</body>
</html>
I've 2 pages. The first ("names1.php) is a form for a user to input info.. this is then sent to the second page where the info is displayed and the mysql database updated.
However.. I can't seem to find the right way of defining the variables.. keep getting "Variables undefined..etc" error messages.
It's probably an incredibly simple error.. but as a newbie in this I'm in need of an expert pair of eyes to find it!
Thanks in advance
Luds
"names1.php"
<html>
<head>
<title>names</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
echo "Please enter the following information.
<form action='processform.php' method='post'>\n
<input type='text' name='firstName'>\n
<input type='text' name='lastName'>\n
<input type='text' name='address' size='30'>\n
<input type='text' name='email'>\n
<input type='submit' value='Go to next page'>\n
</form>\n";
?>
</body>
</html>
"processform.php"
<html>
<head>
</head>
<body>
<h2>You have just entered this information</h2>
<?php
$user="luds";
$host="localhost";
$password="";
$database="invester_names";
$connection = mysql_connect($host,$user,$password) or die
("Couldn't connect to server!"
$db = mysql_select_db($database,$connection) or die ("Couldn't select database"
foreach ($HTTP_POST_VARS as $key => $value)
{
echo "$key- $value<br>";
}
$query = "INSERT INTO personal (firstName,lastName,address,email)
VALUES ('$firstName','$lastName','$address','$email')";
$result = mysql_query($query) or die ("Couldn't execute query."
echo "Database Updated";
?>
</body>
</html>