NYCPHP Meetup

NYPHP.org

[nycphp-talk] simple form action

Ken Robinson kenrbnsn at rbnsn.com
Tue Jan 1 23:42:01 EST 2008


At 11:36 PM 1/1/2008, chad qian wrote:
>Here is the one PHP page code
><?php
>.....
>....
>......
>?>
><html>
><form action=???? method="post" name=form1>
>......
>  <input type="submit" name="Submit" value="Submit">
></form>
>
>When people click "submit", I want to  execute the first php coding 
>part above <html>.
>so,form action=what?

You can just leave the action attribute out of the <form> tag and it 
will be submitted to the same script. Make sure you test that the 
form was submitted before trying to process it.

<?php
if (isset($_POST['submit'])) {
//
//  do form processing
//
}
// other code
?>
<html>
<body>
<form method="post">
...
<form>
</body>
</html>

Ken 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20080101/2036f002/attachment.html>


More information about the talk mailing list