I've been reading about how to do this, and can't find a decent answer.
I want to use a form to post some information to a php function on the same page. How do I do this?
Something like:
<html>
<form method="post" action="#">
<input type="text" name="parameter">
<input type="submit" name="Calculate"
</form>
<?php
- the php code that uses 'parameter' and does something with it -
?>
</html>
Thanks
G
Form action on the same page
Moderator: General Moderators
Re: Form action on the same page
Have you read THIS thread?
Re: Form action on the same page
Ima beginner(have been for years) so I'm happy-go-lucky when I can actually answer a question.
The way I do it is simple.
In the "action=" put a ? and do=whatever...like this...
This way when posting, it will turn into a GET variable you can test for on the same page. For example, like this:
The way I do it is simple.
In the "action=" put a ? and do=whatever...like this...
Code: Select all
<form name="form1" id="form1" action="?do=sendmail" method="post">Code: Select all
<?
if (isset($_GET['do'])) {
# mail actions
switch($_GET['do']) {
#code
}
}
?>