473,414 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Modify $_POST

Hello folks,

Ive seen lots of recommendations to not try to do what Im trying to do
but let me put it this way and hopefully someone can tell if this is a
good idea or not (or an alternative).

What Im trying to do is this. I have a series of links that when
clicked will navigate to a common page passing in a value encoded in
the link. For reasons not worth going into I cant use a querystring.

I was hoping to call a javascript function from the onclick event of
the link, then assign a new $_POST variable and then submit the form
(hence enabling me to read the $_POST value from the receiving page.

Im aware that I could do the same thing with a $_SESSION but as this is
the last stage of this app and I havent had to use sessions yet I was
hoping to avoid it (for no real reason admittedly - I just got
interested in the solution above as an idea).

I hope this is clear.

Regards
Simon Rigby

Jul 24 '06 #1
8 2144
Simon Rigby wrote:
Hello folks,

Ive seen lots of recommendations to not try to do what Im trying to do
but let me put it this way and hopefully someone can tell if this is a
good idea or not (or an alternative).

What Im trying to do is this. I have a series of links that when
clicked will navigate to a common page passing in a value encoded in
the link. For reasons not worth going into I cant use a querystring.

I was hoping to call a javascript function from the onclick event of
the link, then assign a new $_POST variable and then submit the form
(hence enabling me to read the $_POST value from the receiving page.

Im aware that I could do the same thing with a $_SESSION but as this is
the last stage of this app and I havent had to use sessions yet I was
hoping to avoid it (for no real reason admittedly - I just got
interested in the solution above as an idea).

I hope this is clear.

Regards
Simon Rigby
And what happens if the user has javascript disabled?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 24 '06 #2
It fails .. but this is an intranet and Javascript is enabled by
company policy as the intranet makes heavy use of javascript already.

Sorry I should stated that :)

Thanks.
Jerry Stuckle wrote:
Simon Rigby wrote:
Hello folks,

Ive seen lots of recommendations to not try to do what Im trying to do
but let me put it this way and hopefully someone can tell if this is a
good idea or not (or an alternative).

What Im trying to do is this. I have a series of links that when
clicked will navigate to a common page passing in a value encoded in
the link. For reasons not worth going into I cant use a querystring.

I was hoping to call a javascript function from the onclick event of
the link, then assign a new $_POST variable and then submit the form
(hence enabling me to read the $_POST value from the receiving page.

Im aware that I could do the same thing with a $_SESSION but as this is
the last stage of this app and I havent had to use sessions yet I was
hoping to avoid it (for no real reason admittedly - I just got
interested in the solution above as an idea).

I hope this is clear.

Regards
Simon Rigby

And what happens if the user has javascript disabled?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 24 '06 #3
Simon Rigby wrote:
Hello folks,

Ive seen lots of recommendations to not try to do what Im trying to do
but let me put it this way and hopefully someone can tell if this is a
good idea or not (or an alternative).

What Im trying to do is this. I have a series of links that when
clicked will navigate to a common page passing in a value encoded in
the link. For reasons not worth going into I cant use a querystring.

I was hoping to call a javascript function from the onclick event of
the link, then assign a new $_POST variable and then submit the form
(hence enabling me to read the $_POST value from the receiving page.

Im aware that I could do the same thing with a $_SESSION but as this is
the last stage of this app and I havent had to use sessions yet I was
hoping to avoid it (for no real reason admittedly - I just got
interested in the solution above as an idea).

I hope this is clear.

Regards
Simon Rigby
Hi Simon,

I don't think your solution works always.
Look at your demands:
1) No GET encoded information.
2) No Session

So only POST (and COOKIE) remains to pass info around.

Both COOKIE and POST must be populated using Javascript (from a client
browsers viewpoint), and like Jerry said: that can be disabled.

I don't think you can solve this without using GET encoded info, or
demanding the visitor has JS enabled.

A more optimistic note: Learn SESSIONs, you will use them in almost any
mature webapp. So it is time well invested.

Best of luck,

Erwin Moller
Jul 24 '06 #4
"Simon Rigby" <go****@simonrigby.co.ukwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
Hello folks,

Ive seen lots of recommendations to not try to do what Im trying to do
but let me put it this way and hopefully someone can tell if this is a
good idea or not (or an alternative).

What Im trying to do is this. I have a series of links that when
clicked will navigate to a common page passing in a value encoded in
the link. For reasons not worth going into I cant use a querystring.

I was hoping to call a javascript function from the onclick event of
the link, then assign a new $_POST variable and then submit the form
(hence enabling me to read the $_POST value from the receiving page.

So in other words, you'd like to post a form on the click of a link, and
submit a certain value, if I understood your explanation. What would you say
of the following "workaround": change your <a hrefto a form:
<form action="reciever.php" class="pseudolink" method="POST">
<input type="submit"/>
<input type="hidden" name="var" value="val"/>
</form>

and attatch a stylesheet that'll camouflage your form into a harmless
looking link:
<style type="text/css">
..pseudolink {
display:inline;
}
..pseudolink input {
display:inline;
border:none;
backgroundcolor:one;
text-decoration:underline;
cursor:pointer;
color:blue;
}
</style>

I'm just one of the people who wish to avoid javascript whenever it is
possible. I think there's a chance here to do so with the code above. Of
course there will be n+1 forms on the page, I dunno if that's nice then...
Call this the alternative then if you will.

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
sp**@outolempi.net || Gedoon-S @ IRCnet || rot13(xv***@bhgbyrzcv.arg)
Jul 24 '06 #5
Simon Rigby wrote:
Hello folks,

Ive seen lots of recommendations to not try to do what Im trying to do
but let me put it this way and hopefully someone can tell if this is a
good idea or not (or an alternative).

What Im trying to do is this. I have a series of links that when
clicked will navigate to a common page passing in a value encoded in
the link. For reasons not worth going into I cant use a querystring.

I was hoping to call a javascript function from the onclick event of
the link, then assign a new $_POST variable and then submit the form
^^^^^^^^^^^^^^^

You probably mean assign a hidden variable, which will then come back as a
$_POST variable, yes?

Your HTML might be:

<form....
<input type="hidden" name="the_variable" value="">
<a href="SetAndPost('x')">Click here for X</a>
<a href="SetAndPost('y')">Click here for Y</a>

</form>

This code assumes you write a routine called "SetAndPost" that sets the
value of the hidden variable and then submits the form.

--
Kenneth Downs
Secure Data Software, Inc.
(Ken)nneth@(Sec)ure(Dat)a(.com)
Jul 24 '06 #6
Thanks Erwin,

Im not really explaining myself properly. I do understand sessions and
use them regularly and I have no real aversion to using them in this
case, I suppose I just got interested in whether what I proposed was
possible. In short can I declare a post variable that is passed with a
form submission manually instead of it being the result of a form
variable. I did go on to think that I could set the value of a hidden
form <INPUTbased on the value passed from the link.

And as I replied to Jerry, Javascript is available in this instance.

Many thannks for your help, and please dont think Im trying to be
difficult, just wondering if this is possible as opposed to do best
practice etc.

Simon

Erwin Moller wrote:
Simon Rigby wrote:
Hello folks,

Ive seen lots of recommendations to not try to do what Im trying to do
but let me put it this way and hopefully someone can tell if this is a
good idea or not (or an alternative).

What Im trying to do is this. I have a series of links that when
clicked will navigate to a common page passing in a value encoded in
the link. For reasons not worth going into I cant use a querystring.

I was hoping to call a javascript function from the onclick event of
the link, then assign a new $_POST variable and then submit the form
(hence enabling me to read the $_POST value from the receiving page.

Im aware that I could do the same thing with a $_SESSION but as this is
the last stage of this app and I havent had to use sessions yet I was
hoping to avoid it (for no real reason admittedly - I just got
interested in the solution above as an idea).

I hope this is clear.

Regards
Simon Rigby

Hi Simon,

I don't think your solution works always.
Look at your demands:
1) No GET encoded information.
2) No Session

So only POST (and COOKIE) remains to pass info around.

Both COOKIE and POST must be populated using Javascript (from a client
browsers viewpoint), and like Jerry said: that can be disabled.

I don't think you can solve this without using GET encoded info, or
demanding the visitor has JS enabled.

A more optimistic note: Learn SESSIONs, you will use them in almost any
mature webapp. So it is time well invested.

Best of luck,

Erwin Moller
Jul 24 '06 #7
Thanks folks for all your feedback. I do like the idea of the CSS
styled form elements.

Thanks all it seems that there are a number of possible solutions all
of which are better that my original idea.

Thanks again.

Simon

Jul 24 '06 #8
Simon Rigby wrote:
I was hoping to call a javascript function from the onclick event of
the link, then assign a new $_POST variable and then submit the form
(hence enabling me to read the $_POST value from the receiving page.

Im aware that I could do the same thing with a $_SESSION but as this is
the last stage of this app and I havent had to use sessions yet I was
hoping to avoid it (for no real reason admittedly - I just got
interested in the solution above as an idea).
I think people are getting too hung up on the Javascript question and
missed the main issue. The problem with your approach is that it breaks
a number of browser features. Open ing a link in a new window/tab will
not work. Bookmarking will not work. Page saving will not work
correctly. Pressing the back and refresh buttons will bring up warning
messages.

The end-user experience is what matters, not a programmer's preference
for doing things.

Jul 24 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Adrian Parker | last post by:
Is it possible to click on a button, and not have it's value and name stored in _POST? I have this script with a button on it. When you click the button, the page posts to itself. The first...
4
by: Kevin | last post by:
I am having problems in my php code. I am relatively new to php but I know some basics. This is the problem: when i try to echo some information that is typed into form back to the screen i...
15
by: zorro | last post by:
greetings... I'm wondering what more advanced coders would think ot this: $_POST = clean($_POST); and now I can use POST directly: $sql= "select * from T1 where myvar='$_POST' " ;
1
by: RDizzle | last post by:
okay. so all i am doing is changing a registration script that uses $_GET to a script that uses $_POST, but the validation script now returns NULL values for all posted vars. What's the deal? ...
19
by: deko | last post by:
Is it possible to modify the background-image for a certain web page with PHP? I'd like to but a few buttons on the top of a page so readers can select from 2 or 3 different background images (or...
5
by: comp.lang.php | last post by:
// NEW 11/27/2006: FINALLY, IF YOU ADDED OR DELETED OR DID ANY KIND OF FORM ACTION SUCCESSFULLY, DON'T RE-DISPLAY THE NEW EXPENSE ITEMS VIA $_POST if ($_POST && (!is_array($leaseObj->errorArray)...
4
by: kempy535 | last post by:
Hi I get this error code when I try to run my login script. Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\Rising...
3
by: scabman | last post by:
Working on upgrading a site and after moving everything onto a test server (localhost) things started to get real buggy. Went through and checked all my links and everything comes up fine, but it...
8
by: mcserret | last post by:
I know this is a recurring problem that has been addressed here before, but even after reading all that has gone before, I am still stumped. I have a form that is designed to send data to a PHP...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.