Click to See Complete Forum and Search --> : hidden fields (GET form)
Bobby_S
10-29-2005, 09:28 AM
Hey,
I have a form with only hidden fields. Can I send this fields to the
'action' with a click on a link (GET) instead of a click on a button
(POST)?
(a link containing all the hidden values is no solution please)
thx!
LiLcRaZyFuZzY
10-29-2005, 09:41 AM
well, hidden values are not really hidden, they just don't appear, but they still are in the source
Bobby_S
10-29-2005, 11:56 AM
yes, but how can you retrieve them in your action script?
$var1 = $_GET['prm1']
$var2 = $_GET['prm2']
$var3 = $_GET['prm3']
doesn't seem to work
NogDog
10-29-2005, 01:09 PM
If you want your form to send them as get data, just set method="get" in the form tag. If you want to leave them as post data, just change $_GET to $_POST in your script.
felgall
10-29-2005, 03:18 PM
If you want to send the hidden fields via a link instead of a submit button then delete the hidden fields and add the values into the link instead:
<a href="nextpage.html?prm1=aaa&prm2=bbb&prm3=ccc">
LiLcRaZyFuZzY
10-29-2005, 04:10 PM
if it still doesnt work, post your whole code
ray326
10-29-2005, 05:05 PM
click on a link (GET) instead of a click on a button (POST)?The method of the submit has nothing to do with link/button. Just put method="GET" in the form tag.
Bobby_S
10-30-2005, 07:45 AM
Hmm, can't fetch my variables.
Example:
<form action="print.php" method="get" name="printform" target="_blank">
<input type="hidden" name="country" value="Belgie">
<input type="hidden" name="action" value="printform">
<a href="print.php" target="_blank">try this</a>
</form>
print.php:
print $_GET['action'];
is empty...
:(
Bobby_S
10-30-2005, 07:48 AM
If you want to send the hidden fields via a link instead of a submit button then delete the hidden fields and add the values into the link instead:
<a href="nextpage.html?prm1=aaa&prm2=bbb&prm3=ccc">
Indeed, I know it works like this, but can't you keep the variables hidden instead of in a link?
LiLcRaZyFuZzY
10-30-2005, 07:56 AM
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Get form problem</title>
</head>
<body>
<form action="print.php" method="get" name="printform">
<input type="hidden" name="country" value="Belgie">
<input type="hidden" name="action" value="printform">
<input type="submit" value="send">
</form>
</body>
</html>
print.php
<?php
print $_GET['action'];
?>
NogDog
10-30-2005, 10:04 AM
In your .php page, you might want to add the following for debugging purposes, just to see what data, if any, you are receiving:
echo "<pre>";
echo "GET:\n";
print_r($_GET);
echo "\nPOST:\n";
print_r($_POST);
echo "</pre>\n";
Bobby_S
10-30-2005, 10:35 AM
euhm, yes, that's with the submit button.
But is it possible to do with a text link? I guess not if you don't add all variables in the link then?
LiLcRaZyFuZzY
10-30-2005, 10:39 AM
exactly, it is not possible to process data from input elements with a link, but you could style the button to make it look like a link (with CSS)
Bobby_S
10-30-2005, 10:52 AM
ok, I'll try that. Thanks for all help!