05 May 2005

PHP Forms

This is the fun part! sooner or later, we all want to collect user data. We can build nifty data collector using HTML and PHP GET/POST .

Create a HTML form Something like.. Easier if you do it in HTML editor. and name it "myform.html"

<form name="form1" method="post" action="collect.php">
Name :
<input type="text" name="name">
<br>
Email :
<input type="text" name="email">
<br>
<input type="submit" name="Submit" value="Submit">
</form>

Now Create another file, this time "collect.php"
<?php
echo $_POST["name"] ."<br />";
echo $_POST["email"];
?>
That's it... After collecting user information, you can do whatever you want In "collect.php" , send email.. send data to database, evaluate.. or just flush it.. etc

See the output :

myform.html :




collect.php :

No comments: