Page 1 of 1
(solved) Form submission
Posted: Sat Jun 04, 2005 5:49 pm
by davidjwest
I have a simple form which needs submitting, it will then send the details to me by email. After the submit is pressed I want to include a different bit of code.
Code: Select all
<?php
echo "<form method='post' action='mailto:david@foo.org'>";
?>
The problem is where do I put the "echo $_SERVER['PHP_SELF']" so that the code knows the button has been pressed?
Code: Select all
<?php
echo "<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">";
?>
Can I have two actions?
Thanks.
Posted: Sat Jun 04, 2005 5:55 pm
by davidjwest
It appears you can't have two actions on one form, it just executes the first occurence.
Any ideas?
The other bit of code is:
Code: Select all
<?php
if (isset($_POST['submit']))
{
include "centre.php";
}
?>
Posted: Sat Jun 04, 2005 7:35 pm
by Skara
the action attribute tells the form what to do when submit is clicked. It does
not notify anything that something's been done.
$_SERVER['PHP_SELF'] evaluates to the filename of the current script. Therefore, if you put action='{$_SERVER['PHP_SELF']}', then it merely reloads to the same page with the given GET/POST variables set.
Also, you have a
big error in your syntax:
Code: Select all
<?php
echo "<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">";
?>
you have <?php ?> imbedded INSIDE OTHER <?php ?> tags. O.O PLUS, you have " imbedded inside other "!!
With your code, it does something like this...
1) echos "<form action="
2) wtf? <?php is already open!! error.
should be something like this:
Code: Select all
<?php
echo "<form action='{$_SERVER['PHP_SELF']}' method='post'>";
?>
Posted: Sat Jun 04, 2005 7:36 pm
by Skara
wait, I think I see what you're getting at. When action is set to an email address, it doesn't reload the page when you click submit? If that's so, just use javascript to reload it.
