Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/astahost/public_html/rkrt/rkrt_tracker.php on line 186
Submiting Form Data To "file.php?action=login"
Astahost.com   Mar 21, 2010
Open Discussion & Free Web Hosting > Computers & Tech > Programming

Submiting Form Data To "file.php?action=login"

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming

Submiting Form Data To "file.php?action=login"

nightfox
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

Comment/Reply (w/o sign-up)

Houdini
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
echo "<form action='blah.php' method='get'>
<input type='hidden' name='action' value='login'>";
echo "<input type='submit'></form>";
?>
then use the following to access the variable
blah.php
CODE
<?php
echo $_GET['action'];
?>
Does that help answer your question?

Comment/Reply (w/o sign-up)

nightfox
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

Comment/Reply (w/o sign-up)

mastercomputers
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

Comment/Reply (w/o sign-up)

arukomp
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 wink.gif

 

 

 


Comment/Reply (w/o sign-up)

Hercco
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.



QUOTE(arukomp @ Sep 17 2006, 11:20 AM) *

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...
QUOTE(arukomp @ Sep 17 2006, 11:20 AM) *

I hope this helped you a lot wink.gif

I'm most certain that it didnt.





Comment/Reply (w/o sign-up)

minnieadkins
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';

Comment/Reply (w/o sign-up)

demolaynyc
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.

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)




See Also,

*SIMILAR VIDEOS*
Searching Video's for submiting, form, data, file, php, action, login
advertisement




Submiting Form Data To "file.php?action=login"

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com



Creative Commons License