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

free web hosting
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

Reply

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?

Reply

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

Reply

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

Reply

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

 

 

 


Reply

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.





Reply

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

Reply

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.

Reply


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*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : submiting data file php action login

  1. Need Help To Write Code To Upload/download (FTP) - Sending server data... (3)



Looking for submiting, form, data, file, php, action, login

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




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



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE