value passing from html form to php variable
| From: | Wei Wang | Date: | Sat, 01 Jun 2002 15:47:10 +0000 |
| Subject: | value passing from html form to php variable | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-84660@lists.php.net to get a copy of this message | ||
I am not sure if this is the right place to ask this naive question.
I got a simple form addform.html and add.php look like the following.
But everytime I got empty value from firstname and lastname. It seems like
the input value in the html page was not passed on to the php variable $firstname in add.php. Anyone
give me a hand on this naive question?
Great thanks.
Wei
addform.html
<html>
<body>
<form action="add.php" method="post">
First Name : <input type="text" name="firstname" size="40"
length="40" value=""><BR>
Surname : <input type="text" name="surname" size="40"
length="40" value=""><BR>
<input type="submit" name="submit" value="Submit">
<input type="reset" name="reset" value="Clear It">
</form>
</body>
</html>
add.php
<html>
<body>
<?php
$db = pg_connect("dbname=friends");
$query = "INSERT INTO friends (id, firstname, surname) values
(nextval('friends_id_seq'), '$firstname', '$surname')";
$result = pg_exec($db, $query);
if (!$result) {
printf ("ERROR");
$errormessage = pg_errormessage($db);
echo $errormessage;
exit;
}
printf ("These values were inserted into the database - %s %s", $firstname, $surname);
pg_close();
?>
</body>
</html>