|
|
|
|
![]() ![]() |
Jul 17 2006, 09:37 PM
Post
#1
|
|
|
NiGHTFoX - Hiding in the dark Group: Members Posts: 680 Joined: 3-April 05 Member No.: 3,584 |
I've seen it in some other software but I forget where I saw it and how it was done other than this:
In the HTML form: <form action="blah.php" method="post"> <input type="hidden" name="action" value="login"> <input.... ... So, would that submit to blah.php?action=login? Thanks, [N]F |
|
|
|
Jul 17 2006, 11:58 PM
Post
#2
|
|
|
Super Member Group: Members Posts: 572 Joined: 25-April 05 From: Nashville Tennessee Member No.: 4,340 |
Well under normal circumstance the code you have would work, but as written the variable 'action' is a POST variable. so to pass the hidden field variable 'action' you would have to change your code to method-'get' like the below.
CODE <?php then use the following to access the variableecho "<form action='blah.php' method='get'> <input type='hidden' name='action' value='login'>"; echo "<input type='submit'></form>"; ?> blah.php CODE <?php Does that help answer your question?
echo $_GET['action']; ?> This post has been edited by Houdini: Jul 17 2006, 11:59 PM |
|
|
|
Jul 18 2006, 02:23 AM
Post
#3
|
|
|
NiGHTFoX - Hiding in the dark Group: Members Posts: 680 Joined: 3-April 05 Member No.: 3,584 |
Not really... I mean, from what I saw it was actually passing information through the POST method. I mean, I don't want to send sensitive information like passwords through GET. I wish I remember what it was that I saw using it... gosh darn it... grr... what was it called?!?
[N]F |
|
|
|
Jul 18 2006, 08:22 AM
Post
#4
|
|
|
BUG.SWAT.PATROL Group: Members Posts: 626 Joined: 1-September 04 From: Auckland, New Zealand Member No.: 27 |
If you've looked at AJAX it's possibly something you picked up there.
Are you meaning that you want to send the information to blah.php?action=login Which means your form line would be like CODE <form action="blah.php?action=login" method="post"> That way you're doing a get request with the action=login, and also posting data along with it to that URL. Other than this, we'd probably be stumped about what you're talking about. Cheers, MC |
|
|
|
Sep 17 2006, 08:20 AM
Post
#5
|
|
|
Newbie [ Level 2 ] Group: Members Posts: 11 Joined: 3-September 06 Member No.: 15,694 |
Another example if you didn't understand:
CODE <form action="blah.php" action="POST"> <input type="hidden" name="action" value="login"> <input type="submit" name="submit" value="Go"> </form> <?php if ($_GET['action'] == 'login') { // some code here.... } else { // some other code here.... } ?> When you post something with form and with POST method, it's a good idea to use $_GET['string'] to get string values. Another example: CODE <form action="login.php" action="POST"> <input type="text" name="login"> <input type="text" name="pass"> <input type="submit" name="submit" value="Login"> </form> <?php if ($submit) { // if form has been submited if ($_GET['login'] == $adminlogin) && $_GET['pass'] == $adminpass) { header("Location: adminpanel.php"); } else { header("Location: login.php"); } } Also, if you are posting data to the same page where form is, then you could use <?php $PHP_SELF ?> in "action" instead of "login.php". I hope this helped you a lot |
|
|
|
Sep 30 2006, 06:59 AM
Post
#6
|
|
|
Super Member Group: Members Posts: 595 Joined: 4-September 04 Member No.: 228 |
Nightfox, I think I know where you're coming from... You want to post both GET and POST data at once. Sounds pointless? Well it's not completely.
I've used that method for pages that use a same PHP script to present all different pages, varying the content based on the GET variables. Sometimes it happens that you want to use a form on such page and sending it all through GET would get you really messy URLs and it could be that the information is delicate. On the otherhand using POST for everything would be inconvenient as user would not get a direct URL to the page and also because you'd might have to rewrite the page generating PHP script. Oh and it does work, juts put the GET variables in end of the URL in the action argument and use POST as the method. When you post something with form and with POST method, it's a good idea to use $_GET['string'] to get string values. What the... I hope this helped you a lot I'm most certain that it didnt. |
|
|
|
Oct 1 2006, 04:12 PM
Post
#7
|
|
|
Premium Member Group: Members Posts: 292 Joined: 15-December 04 Member No.: 1,768 |
The action of your form can have a query string if you're using post.
I.E. HTML <form name="SomeForm" action="Action.php?page=main&lang=en" method="POST"> Login:<input type="text" name="user" value="" /> Password:<input type="text" name="pwd" value="" /> </form> I'm not what sure you're trying to do, or what you're actually talking about. But I think that's something similiar. Don't forget that you can change the action of your form at any time with the DOM. document.forms[0].aciton='somaction.php?foo=bar'; |
|
|
|
Jan 9 2007, 04:58 PM
Post
#8
|
|
|
Premium Member Group: Members Posts: 330 Joined: 2-February 06 Member No.: 11,040 |
There are various ways of going about this. One is to change "post" to "get" if you would like to place the variables next to the url. However, if you want to keep it hidden, use post and to retrieve the variables value from the next page you would have to use: <? $_POST[variablename] ?>
Of course you replace "variablename" with your variable. |
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 8th September 2008 - 03:54 AM |