Page 1 of 1

Is ther a posibility to send variables back to same page....

Posted: Mon Nov 11, 2002 4:10 am
by Skywalker
Is ther a posibility to send variables back to same page. With php_self?

I have a form, that has a send button (hehe) but the inserted values have to be send to the same page back again. it works like some kind of refresh.


doe I have to do it like this then or do I have to use php_self?

<form method="post" action="php_self">?
or
<form method="post" action="the name of this page.php">?

witch one is beter to use?

Thenk for you help, Skywalker

Posted: Mon Nov 11, 2002 4:14 am
by twigletmac
You can use either $_SERVER['PHP_SELF'] or the page's actual name as the action in the form. Using $_SERVER['PHP_SELF'] means that if you change the name of the file you don't have to worry about editing the HTML.

Mac

Re: Is ther a posibility to send variables back to same page

Posted: Mon Nov 11, 2002 6:51 am
by Heavy
Skywalker wrote:

Code: Select all

<form method="post" action="php_self">
Most people understand, but for other newbies, like me, let's correct the above:

Code: Select all

<form method="post" action="<?=$_SERVER&#1111;'PHP_SELF']?>">

Posted: Mon Nov 11, 2002 7:03 am
by twigletmac
Don't forget that not everybody has short tags (<? ?>) enabled so for newbies it's good to point out:

Code: Select all

&lt;form method="post" action="&lt;?php echo $_SERVER&#1111;'PHP_SELF']; ?&gt;"&gt;
too.

Mac

Posted: Mon Nov 11, 2002 8:01 am
by volka
most browsers (all I got to know until now) will send back the data to the same url if the action-property is missing, e.g.

Code: Select all

<form method="POST">
	<input type="submit" name="submit" value="true" />
</form>
It works but does not comply to any :?: standard and http://validator.w3.org/check will not approve the document ;)

Posted: Mon Nov 11, 2002 8:49 am
by Skywalker
Ok thenk you people :D