Forum Moderators: coopster
Im learning php and I just cant get forms to work. Im using easyphp.
My html code is
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>9.2 simple form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action "listing9.3.php">
<input type ="text" name="user">
<br>
<textarea name="address" rows="5" cols="40">
</textarea>
<br>
<input type="submit" value="hit it">
</form>
</body>
</html>
and my php file is
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>read form 9.2</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
print "Welcome <b> $user</b><P>\n\n";
print "Your address is <P>\n\n<b>$address</b>;
?>
</body>
</html>
and when I post 'John' from 'London' all I see is
http://example.com/Listing9.2.html?user=john&address=london
in the address and the original form on the page. This happens whatever php file I have entered as the action script so is there something wrong with my setup?
many thanks,Shumit
[edited by: dreamcatcher at 1:57 pm (utc) on April 13, 2008]
[edit reason] Use example.com, thanks. [/edit]
Try to POST your form
<form method="POST" action="listing9.3.php">
Then on your listing9.3.php page
Accept the variables
<?php
$user = $_POST['user'];
$address = $_POST['address'];
print "Welcome <b> $user</b><P>\n\n";
print "Your address is <P>\n\n<b>$address</b>;
?>
See if that works
Listing9.2.html?user=john&address=london
You can, via htaccess, call php within an html document, but I somehow doubt you are doing that, so, are you sure everything is correct? are you sure the equals sign ( = ) is before listing.9.2 in the action
action="list...
try this at the top of listing9.2.php
print_r ($_POST);
See what it returns, it's an easy way to spot if your variables are actually arriving.
Also try and add the missing " on this line
print "Your address is <P>\n\n<b>$address</b>HERE;<---