Quote:
|
Originally Posted by dark_omen
How would that look though, just have the $_POST['']'s in a <?php ... ?> tags right after the form, or would it be done differently?
|
Maybe an example would be appropriate here:
[php]
<form action="" method="post">
<p>Name: <input type="text" name="name" /></p>
<p><input type="submit" /></p>
</form>
<?php
if ($_POST['submit']) {
echo "Your name is " . $_POST['name'];
}
?>[/php]The above code places the form, and the PHP code, on the same page. The empty action attribute on the form tag tells the browser to send the information on the form to the current page.
You can also split it:
index.php
[php]
<form action="formsubmit.php" method="post">
<p>Name: <input type="text" name="name" /></p>
<p><input type="submit" /></p>
</form>[/php]
formsubmit.php
[php]<?php echo "Your name is " . $_POST['name']; ?>[/php]The "if submit" statement isn't needed in this case, as we can reasonably assume that formsubmit.php will only be accessed through the form in index.php.
However, as DaWei says, learning the basics of PHP is best learnt elsewhere. Try googling "PHP tutorial".