[PHP] Forms and PHP_SELF
Hi, I have a very simple form that searches a MySQL database and I want to be able to have the search appear on the same page as the search. FORM NAME=search METHOD=post ACTION=? $PHP_SELF; ? INPUT type=text size=30 name=player INPUT TYPE=image src=../images/submit.gif width=75 height30 value=submit /FORM The part that confuses me is how I run the code for the search. Currently I have it in a function and at the top of the script I have an IF statement that checks to see if the submit button has been pressed, if it has I go to the function. This is not working, and I'm not even sure this is the right way to go about it. I'm probably doing this wrong and would appreciate it if someone could set me straight. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms and PHP_SELF
For print $PHP_SELF, or $_SERVER['PHP_SELF'] use: ?php echo $_SERVER['PHP_SELF']; ? or the shortcur sintax: ?=$_SERVER['PHP_SELF']? (if short_open_tag = On in php.ini) - Original Message - From: Beauford.2005 [EMAIL PROTECTED] To: PHP [EMAIL PROTECTED] Sent: Sunday, July 06, 2003 1:43 AM Subject: [PHP] Forms and PHP_SELF Hi, I have a very simple form that searches a MySQL database and I want to be able to have the search appear on the same page as the search. FORM NAME=search METHOD=post ACTION=? $PHP_SELF; ? INPUT type=text size=30 name=player INPUT TYPE=image src=../images/submit.gif width=75 height30 value=submit /FORM The part that confuses me is how I run the code for the search. Currently I have it in a function and at the top of the script I have an IF statement that checks to see if the submit button has been pressed, if it has I go to the function. This is not working, and I'm not even sure this is the right way to go about it. I'm probably doing this wrong and would appreciate it if someone could set me straight. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms and PHP_SELF
Dan Anderson wrote: Be careful when using PHP self. Not all servers support it. If you're planning on using this script over and over on multiple servers you may find creating a variable is helpful. $some_variable = the_script_name.php; Then, where you would use PHP_SELF just echo (or whatever) $some_variable. You will have to change it if the script name changes, but otherwise it's just a relative path. Please don't mislead users! That's plain untrue. You're correct that not all servers have register_globals on, so use $HTTP_SERVER_VARS['PHP_SELF']. -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms and PHP_SELF
Please don't mislead users! That's plain untrue. I assure you that server administrators can turn off the variables such as PHP SELF. It may not be common but it does happen. -Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms and PHP_SELF
Dan Anderson wrote: I assure you that server administrators can turn off the variables such as PHP SELF. It may not be common but it does happen. The only way to do that would be editing the PHP source. That's above the IQ of any sysadmin who would want to do that. -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Forms and PHP_SELF
I'm currently working on a project and I've come across a problem which I'm sure has been discussed several times before but I still need some assistance on it. I have a page with a form whose action is $PHP_SELF so the form and the form action are all in the same pagethis works fine but in the form action a message is displayed stating success or failure of the insertion of data into a database and the user is redirected by means of a meta refershduring this time if the user refreshes the page the data is resubmitted againthe user can do this repeatedly Some people have suggested that I use headers but I cannot do this at this point because I've already sent the header... others have suggested I use some variable $script_ran_count = 1 then run and after increment so a test of it would be false...this had no effect others have suggested javascript... I'm really baffled...how can I have a self-submitting form page that has a display message and a meta redirect but if the user refreshes the page stop the resumission of data? Regards, Chad Guilette -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Forms and PHP_SELF
surely all you need to do is put the php right at the top, and say if (isset($variable) { print this message } else {do this header (); } i've done that loads of times so the form data goes back to the page, and once its inserted into the db, it sends a header to redirect. /sunny -Original Message- From: Chad Guilette [mailto:[EMAIL PROTECTED]] Sent: 10 May 2001 16:07 To: [EMAIL PROTECTED] Subject: [PHP] Forms and PHP_SELF I'm currently working on a project and I've come across a problem which I'm sure has been discussed several times before but I still need some assistance on it. I have a page with a form whose action is $PHP_SELF so the form and the form action are all in the same pagethis works fine but in the form action a message is displayed stating success or failure of the insertion of data into a database and the user is redirected by means of a meta refershduring this time if the user refreshes the page the data is resubmitted againthe user can do this repeatedly Some people have suggested that I use headers but I cannot do this at this point because I've already sent the header... others have suggested I use some variable $script_ran_count = 1 then run and after increment so a test of it would be false...this had no effect others have suggested javascript... I'm really baffled...how can I have a self-submitting form page that has a display message and a meta redirect but if the user refreshes the page stop the resumission of data? Regards, Chad Guilette -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Forms and PHP_SELF
or if you're hellbent on using one form, you could set a cookie db_insert_formname=1; so that if the page refreshes, you can check the value of the cookie to make sure you dont re-insert the data -Original Message- From: Sandeep Hundal [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 10, 2001 11:11 AM To: 'Chad Guilette'; [EMAIL PROTECTED] Subject: RE: [PHP] Forms and PHP_SELF surely all you need to do is put the php right at the top, and say if (isset($variable) { print this message } else {do this header (); } i've done that loads of times so the form data goes back to the page, and once its inserted into the db, it sends a header to redirect. /sunny -Original Message- From: Chad Guilette [mailto:[EMAIL PROTECTED]] Sent: 10 May 2001 16:07 To: [EMAIL PROTECTED] Subject: [PHP] Forms and PHP_SELF I'm currently working on a project and I've come across a problem which I'm sure has been discussed several times before but I still need some assistance on it. I have a page with a form whose action is $PHP_SELF so the form and the form action are all in the same pagethis works fine but in the form action a message is displayed stating success or failure of the insertion of data into a database and the user is redirected by means of a meta refershduring this time if the user refreshes the page the data is resubmitted againthe user can do this repeatedly Some people have suggested that I use headers but I cannot do this at this point because I've already sent the header... others have suggested I use some variable $script_ran_count = 1 then run and after increment so a test of it would be false...this had no effect others have suggested javascript... I'm really baffled...how can I have a self-submitting form page that has a display message and a meta redirect but if the user refreshes the page stop the resumission of data? Regards, Chad Guilette -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Forms and PHP_SELF
Chad Guilette [EMAIL PROTECTED] wrote in message 000701c0d962$d28fb670$0100a8c0@optimus">news:000701c0d962$d28fb670$0100a8c0@optimus... I'm currently working on a project and I've come across a problem which I'm sure has been discussed several times before but I still need some assistance on it. I have a page with a form whose action is $PHP_SELF so the form and the form action are all in the same pagethis works fine but in the form action a message is displayed stating success or failure of the insertion of data into a database and the user is redirected by means of a meta refershduring this time if the user refreshes the page the data is resubmitted againthe user can do this repeatedly Some people have suggested that I use headers but I cannot do this at this point because I've already sent the header... Well You can use output buffering see ob_start(); others have suggested I use some variable $script_ran_count = 1 then run and after increment so a test of it would be false...this had no effect others have suggested javascript... I'm really baffled...how can I have a self-submitting form page that has a display message and a meta redirect but if the user refreshes the page stop the resumission of data? Regards, Chad Guilette -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]