Computer Webmaster Gaming Console Graphics Forum

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.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > PHP
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

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.

Google
Reply
 
LinkBack Thread Tools Display Modes
Old 05-20-2007, 5:33 PM   #1
kenoli
 
kenoli's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default When is $_POST set and unset?

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

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Advertisements
Old 05-20-2007, 5:33 PM   #2
Mike P2
 
Mike P2's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default When is $_POST set and unset?

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

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 05-20-2007, 5:33 PM   #3
shimmyshack
 
shimmyshack's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default When is $_POST set and unset?

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

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 05-20-2007, 5:33 PM   #4
kenoli
 
kenoli's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default When is $_POST set and unset?

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



 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 05-20-2007, 5:33 PM   #5
shimmyshack
 
shimmyshack's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default When is $_POST set and unset?

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.

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 05-20-2007, 5:33 PM   #6
kenoli
 
kenoli's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default When is $_POST set and unset?

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.



 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 05-20-2007, 5:33 PM   #7
Tom
 
Tom's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default When is $_POST set and unset?


"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



 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 05-20-2007, 5:33 PM   #8
J.O. Aho
 
J.O. Aho's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default When is $_POST set and unset?

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
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 05-20-2007, 5:33 PM   #9
kenoli
 
kenoli's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default When is $_POST set and unset?

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



 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Featured Websites
Free Space
Free Space
Free Space Free Space
Reply
Tags: , ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Featured Websites




All times are GMT +1. The time now is 6:55 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98