![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| I have a script that submits form data via a "post" method to another script. I have an href link in the destination script that links back to itself for processing form data on that page with some "get" data appended to the URL. I noticed that after clicking on that link and sending the action back to itself, a check of isset($_POST) returns true while displaying the content of $_POST displays an empty array. I had expected isset($_POST) to return false, thinking the script would unset the $_POST array when the <a> link sent it back to itself. Instead, it leaves $_POST set but empty. What is the convention here? --Kenoli | |||
|
| Advertisements |
| | #2 | ||
| On May 15, 7:38 pm, kenoli <kenol...@gmail.com> wrote: > I have a script that submits form data via a "post" method to another > script. I have an href link in the destination script that links back > to itself for processing form data on that page with some "get" data > appended to the URL. I noticed that after clicking on that link and > sending the action back to itself, a check of isset($_POST) returns > true while displaying the content of $_POST displays an empty array. > I had expected isset($_POST) to return false, thinking the script > would unset the $_POST array when the <a> link sent it back to > itself. Instead, it leaves $_POST set but empty. > > What is the convention here? > > --Kenoli You should check if some variable from the posting form is set instead of the entire $_POST. The submit button or something like that. If the variables are the same for some reason, you can add a hidden field in the posting form and check if that is set. -Mike PII | |||
|
| | #3 | ||
| On May 16, 1:24 am, Mike P2 <sumguyovrt...@gmail.com> wrote: > On May 15, 7:38 pm, kenoli <kenol...@gmail.com> wrote: > > > I have a script that submits form data via a "post" method to another > > script. I have an href link in the destination script that links back > > to itself for processing form data on that page with some "get" data > > appended to the URL. I noticed that after clicking on that link and > > sending the action back to itself, a check of isset($_POST) returns > > true while displaying the content of $_POST displays an empty array. > > I had expected isset($_POST) to return false, thinking the script > > would unset the $_POST array when the <a> link sent it back to > > itself. Instead, it leaves $_POST set but empty. > > > What is the convention here? > > > --Kenoli > > You should check if some variable from the posting form is set instead > of the entire $_POST. The submit button or something like that. If the > variables are the same for some reason, you can add a hidden field in > the posting form and check if that is set. > > -Mike PII you could use if( !isset($_POST) || empty($_POST) ) since if the form is posted without being filled $_POST still wont be empty | |||
|
| | #4 | ||
| There is a form on the page with a post method and some submit buttons, however, none of them are triggered here. The script is called using an <a>tag with this kind of thing: <a href = "<? echo 'http://' . $_SERVER['PHP_SELF'] . '?pid=' . $row[id]; ?>" >Delete</a> It just leaves the page and starts again at the top of the script. It works fine. What caused me to catch it is that I was using: if (!isset($_POST)) to set a switch variable in the case that the data had not been sent via a post submit. It wasn't working so I checked and found the $_POST variable was sure enough set, but empty. What would be setting the $_POST variable if the form wasn't triggered. --Kenoli On May 15, 5:24 pm, Mike P2 <sumguyovrt...@gmail.com> wrote: > On May 15, 7:38 pm, kenoli <kenol...@gmail.com> wrote: > > > I have a script that submits form data via a "post" method to another > > script. I have an href link in the destination script that links back > > to itself for processing form data on that page with some "get" data > > appended to the URL. I noticed that after clicking on that link and > > sending the action back to itself, a check of isset($_POST) returns > > true while displaying the content of $_POST displays an empty array. > > I had expected isset($_POST) to return false, thinking the script > > would unset the $_POST array when the <a> link sent it back to > > itself. Instead, it leaves $_POST set but empty. > > > What is the convention here? > > > --Kenoli > > You should check if some variable from the posting form is set instead > of the entire $_POST. The submit button or something like that. If the > variables are the same for some reason, you can add a hidden field in > the posting form and check if that is set. > > -Mike PII | |||
|
| | #5 | ||
| On May 16, 6:05 am, kenoli <kenol...@gmail.com> wrote: > There is a form on the page with a post method and some submit > buttons, however, none of them are triggered here. The script is > called using an <a>tag with this kind of thing: > > <a href = "<? echo 'http://' . $_SERVER['PHP_SELF'] . '?pid=' . > $row[id]; ?>" >Delete</a> > > It just leaves the page and starts again at the top of the script. It > works fine. What caused me to catch it is that I was using: > > if (!isset($_POST)) > > to set a switch variable in the case that the data had not been sent > via a post submit. It wasn't working so I checked and found the > $_POST variable was sure enough set, but empty. > > What would be setting the $_POST variable if the form wasn't > triggered. > > --Kenoli > > On May 15, 5:24 pm, Mike P2 <sumguyovrt...@gmail.com> wrote: > > > On May 15, 7:38 pm, kenoli <kenol...@gmail.com> wrote: > > > > I have a script that submits form data via a "post" method to another > > > script. I have an href link in the destination script that links back > > > to itself for processing form data on that page with some "get" data > > > appended to the URL. I noticed that after clicking on that link and > > > sending the action back to itself, a check of isset($_POST) returns > > > true while displaying the content of $_POST displays an empty array. > > > I had expected isset($_POST) to return false, thinking the script > > > would unset the $_POST array when the <a> link sent it back to > > > itself. Instead, it leaves $_POST set but empty. > > > > What is the convention here? > > > > --Kenoli > > > You should check if some variable from the posting form is set instead > > of the entire $_POST. The submit button or something like that. If the > > variables are the same for some reason, you can add a hidden field in > > the posting form and check if that is set. > > > -Mike PII try it with GET, COOKIE, REQUEST, FILES, SESSION, all will be set but empty (if you arent populating them). they are superglobals, always set in the current scope. | |||
|
| | #6 | ||
| Thanks. Yeah, I tried it in a new script with nothing except: if (isset($_POST)) { echo "Is set!"; } else { echo "Is not set."; } Output: Is set! It is definitely set. Learn something everyday. Super globals are always set. Got it. --Kenoli On May 16, 2:30 am, shimmyshack <matt.fa...@gmail.com> wrote: > On May 16, 6:05 am, kenoli <kenol...@gmail.com> wrote: > > > > > There is a form on the page with a post method and some submit > > buttons, however, none of them are triggered here. The script is > > called using an <a>tag with this kind of thing: > > > <a href = "<? echo 'http://' . $_SERVER['PHP_SELF'] . '?pid=' . > > $row[id]; ?>" >Delete</a> > > > It just leaves the page and starts again at the top of the script. It > > works fine. What caused me to catch it is that I was using: > > > if (!isset($_POST)) > > > to set a switch variable in the case that the data had not been sent > > via a post submit. It wasn't working so I checked and found the > > $_POST variable was sure enough set, but empty. > > > What would be setting the $_POST variable if the form wasn't > > triggered. > > > --Kenoli > > > On May 15, 5:24 pm, Mike P2 <sumguyovrt...@gmail.com> wrote: > > > > On May 15, 7:38 pm, kenoli <kenol...@gmail.com> wrote: > > > > > I have a script that submits form data via a "post" method to another > > > > script. I have an href link in the destination script that links back > > > > to itself for processing form data on that page with some "get" data > > > > appended to the URL. I noticed that after clicking on that link and > > > > sending the action back to itself, a check of isset($_POST) returns > > > > true while displaying the content of $_POST displays an empty array. > > > > I had expected isset($_POST) to return false, thinking the script > > > > would unset the $_POST array when the <a> link sent it back to > > > > itself. Instead, it leaves $_POST set but empty. > > > > > What is the convention here? > > > > > --Kenoli > > > > You should check if some variable from the posting form is set instead > > > of the entire $_POST. The submit button or something like that. If the > > > variables are the same for some reason, you can add a hidden field in > > > the posting form and check if that is set. > > > > -Mike PII > > try it with GET, COOKIE, REQUEST, FILES, SESSION, all will be set but > empty (if you arent populating them). > they are superglobals, always set in the current scope. | |||
|
| | #7 | ||
| "kenoli" <kenoli.p@gmail.com> wrote in message news:1179272305.382461.25810@p77g2000hsh.googlegro ups.com... > I have a script that submits form data via a "post" method to another > script. I have an href link in the destination script that links back > to itself for processing form data on that page with some "get" data > appended to the URL. I noticed that after clicking on that link and > sending the action back to itself, a check of isset($_POST) returns > true while displaying the content of $_POST displays an empty array. > I had expected isset($_POST) to return false, thinking the script > would unset the $_POST array when the <a> link sent it back to > itself. Instead, it leaves $_POST set but empty. > > What is the convention here? > > --Kenoli > Rather than testing for $_POST, I'd add a hidden form field so you can test if that was specifically submitted. Tom -- Newsguy.com - Express Accounts - 30 GB $9.95 / month | |||
|
| | #8 | ||
| kenoli wrote: > I have a script that submits form data via a "post" method to another > script. I have an href link in the destination script that links back > to itself for processing form data on that page with some "get" data > appended to the URL. I noticed that after clicking on that link and > sending the action back to itself, a check of isset($_POST) returns > true while displaying the content of $_POST displays an empty array. > I had expected isset($_POST) to return false, thinking the script > would unset the $_POST array when the <a> link sent it back to > itself. Instead, it leaves $_POST set but empty. if you have a <input type="text" name="something" value=""> then test against the something cell in the $_POST: isset($_POST['something']) -- //Aho | |||
|
| | #9 | ||
| Thanks. What triggered all of this was the need to pass various values between scripts to various variables in the receiving script, some connected naturally to a form field and some not. Sometimes they are the result of a database query or sometimes the result of an operator like a switch statement. There are obviously various ways to do this, e.g. "get" pairs in a URL, session variables, name value pairs in a hidden field, And then the receiving script needs a trigger to know which value to use. I'm seeing the significant variety of ways php provides to accomplish both these functions. As I'm coding, things seem to start out by getting complicated fast and then collapsing into more simplified structures as I start to see the patterns. One thing that seems particularly valuable is being able to see the symetries that can be collapsed into triggered choices. --Kenoli On May 16, 11:20 am, "J.O. Aho" <u...@example.net> wrote: > kenoli wrote: > > I have a script that submits form data via a "post" method to another > > script. I have an href link in the destination script that links back > > to itself for processing form data on that page with some "get" data > > appended to the URL. I noticed that after clicking on that link and > > sending the action back to itself, a check of isset($_POST) returns > > true while displaying the content of $_POST displays an empty array. > > I had expected isset($_POST) to return false, thinking the script > > would unset the $_POST array when the <a> link sent it back to > > itself. Instead, it leaves $_POST set but empty. > > if you have a <input type="text" name="something" value=""> then test against > the something cell in the $_POST: isset($_POST['something']) > > -- > > //Aho | |||
|
| Featured Websites | ||||
|
![]() |
| Tags: set, unset, _post |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| Featured Websites | ||||
|