473,387 Members | 1,749 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,387 software developers and data experts.

setting _post

is there a way to set _post variables without submitting a form?

something like

<?php
$_POST['var1']=123;
?>
<a href="something.php">link</a>

when user clicks on a link the something.php script can access
$_POST['var1']

Regards,

Vedran
Jul 17 '05 #1
4 9362
On Sat, 12 Mar 2005 23:37:19 +0100, "B.r.K.o.N.j.A." <th********@inet.hr>
wrote:
is there a way to set _post variables without submitting a form?

something like

<?php
$_POST['var1']=123;
?>
<a href="something.php">link</a>

when user clicks on a link the something.php script can access
$_POST['var1']


No. "Clicking a link" implies "GET".

Maybe there's a way with Javascript, submitting a method="post" form through
an onClick handler; try comp.lang.javascript if you want to try that
(unreliable) method.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2

"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:7g********************************@4ax.com...
On Sat, 12 Mar 2005 23:37:19 +0100, "B.r.K.o.N.j.A." <th********@inet.hr>
wrote:
is there a way to set _post variables without submitting a form? when user clicks on a link the something.php script can access
$_POST['var1']


No. "Clicking a link" implies "GET".

Maybe there's a way with Javascript, submitting a method="post" form
through
an onClick handler; try comp.lang.javascript if you want to try that
(unreliable) method.


this page: http://tom.me.uk/scripting/submit.asp gives a way around the
possibility of the user not having js, also, gives a way of doing it with
css.

I was wondering about this myself, thanks for reminding me.

So, I was wondering the pros and cons of doing this. It's be a pain when
you're trouble shooting, you wouldn't have an easy way of telling which
variables had been sent. The user couldn't bookmark your pages(well, they
would get the page with no variables set).

--
juglesh

Jul 17 '05 #3
B.r.K.o.N.j.A. wrote:
is there a way to set _post variables without submitting a form?

something like

<?php
$_POST['var1']=123;
?>
<a href="something.php">link</a>

when user clicks on a link the something.php script can access
$_POST['var1']

Regards,

Vedran


It seems that what you want is for "var1" to exist and have the value 123
when the user goes to "something.php". Is this what you want? If so, then
the simplest is this:

<a href="something.php?var1=123">link</a>

....and then the variable will be in $_GET instead of $_POST, but what's the
difference?

If you want to get more complicated, you will need javascript, which IMHO is
actually a very good thing. In my world all of my users have this so it is
not a problem, but in some circles that would be a problem.

--
Kenneth Downs
Secure Data Software, Inc.
(Ken)nneth@(Sec)ure(Dat)a(.com)
Jul 17 '05 #4
...and then the variable will be in $_GET instead of $_POST, but what's the difference?


Well, there's a limit of _GET variables length, _POST doesn't have that
limitation (which is crucial for my choice of _POST over _GET)... well I
think I'll use session, objects and serialization ... that ought to do the
trick ... For what it's worth, I'm trying to make a display search result
script which allows user to choose "page" of results to go to (links) and
therefore I need to resend all the search words too... I'm trying to do this
cleanly and neatly so I can reuse this script many times :)

Regards,

Vedran
Jul 17 '05 #5

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

Similar topics

2
by: Sarah Michael | last post by:
Hi, I am running the following code to set a cookie but it is not working, please help me sorting out the problem. The code is from an online article http://www.devarticles.com/art/1/639 I...
4
by: Sims | last post by:
Hi, Is it wrong to forcefully set a value HTTP_GET_VARS and HTTP_POST_VARS $HTTP_GET_VARS = 'bar'? If yes, why? and how can i pass value between one page and the other without using the url?...
9
by: Don Seckler | last post by:
I am trying to set up a PHP web page so I can enter data into a database. I created a form: <form action="admin_news_insert_processor.php" method="post" name="frm_Insert_News"...
4
by: Tamer Higazi | last post by:
Hi! I wrote a small script setting a cookie.... but nothing is being set. What could be the problem?! Did I make something wrong?! One script is used to ask for the cookie and the other one shows...
15
by: Sonnich | last post by:
Hi all! I have a file where I'd have to submit buttons, and I need to differ between those. Step #1 - open html win with default selection Step #2 - user may select some criteries for the...
1
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
4
by: Robert S | last post by:
I have a form with a checkbox: <form method="post" action="test.php"> <input type="checkbox" name="foo" checked> <input type="submit"> </form> If the checkbox is checked, $_POST gets...
3
by: gsherp | last post by:
I have a html page with a drop menu select name=color (....a list of colors) I select the color to be blue. in my php code I have <?php $color = $_POST; //$color = blue from form...
8
by: SpiritBreaker | last post by:
I am having problems getting the $_SESSION to set, the $_SESSION will work fine when its first gets the value, however, when I go to another page, the $_SESSION then loses its value. So if any one...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.