Wednesday, 7 August 2013

PHP-Submit a form to different pages according to variable values

PHP-Submit a form to different pages according to variable values

I was wondering in php web page, like
<form method = "post" action = ?>
Age: <input type = "text" name="age">
Submit: <input type="submit">
</form>
for example, if the input age larger than 18, then go to page: a.php; else
goto b.php
How can we fulfil that, in this current page or do it in the next
forwarding page?
More specifically,
if we want to do it in current page,
what I think is action="function()", and inside the function, we do the
judgement to go to a.php or b.php. But what is the correct way to write
the action and function()? And I saw using onclick="..." as well, what is
the difference?
if we want to do it in the next page,
we can write action="c.php" and do the judgement in the c.php page. If so,
how to do that in the c.php page?
btw, which way is a common used way?
Thanks, Eve

No comments:

Post a Comment