Jump to content

Is my code a GET or a POST ??


scanreg

Recommended Posts

I have the following form tag:

 

<form action="?editform" method="post">

 

The php in my index.php file goes like this:

 

if (isset($_GET['editform']))

....etc.

 

I admit, I'm confused.

 

Is the form above a GET or a POST?

 

Many thanks  :)

Link to comment
Share on other sites

action="?editform" causes a GET variable, editform, to be appended to the URL.

 

When the form is submitted, you will have $_GET['editform'] but the form fields will be $_POST variables.

 

Your code is correct for detecting that your form was submitted.

Link to comment
Share on other sites

I have the following form tag:

 

<form action="?editform" method="post">

 

The php in my index.php file goes like this:

 

if (isset($_GET['editform']))

....etc.

 

I admit, I'm confused.

 

Is the form above a GET or a POST?

 

Many thanks  :)

 

If you look in the opening form tag, you can see what method the form is, by looking for the method=".." attribute.  it will either say "get" or "post"

Link to comment
Share on other sites

Since you're new I'll give you a small piece of heads up in terms of security.

 

Do not send sensitive information over GET because the web server will typically log requested URLs, including the GET variables.

 

Because logs are plain-text and all sorts of crazy things happen to them (they get archived, they're sent to dev teams for debugging and error fixing, etc.) it's best to not have anything sensitive in them.

 

I hope that makes sense.

Link to comment
Share on other sites

Since you're new I'll give you a small piece of heads up in terms of security.

 

Do not send sensitive information over GET because the web server will typically log requested URLs, including the GET variables.

 

Because logs are plain-text and all sorts of crazy things happen to them (they get archived, they're sent to dev teams for debugging and error fixing, etc.) it's best to not have anything sensitive in them.

 

I hope that makes sense.

 

Yes, absolutely, that has been hammered into my head, that's one of the reasons why I'm trying to understand how a "post" form is somehow resulting in a "get"

 

Many thanks

Link to comment
Share on other sites

If you put ?editform into a hidden field you can work the whole form using the $_POST request...

 

<input type="hidden" name="editform" />
if (isset($_POST['editform']))

 

But there's nothing wrong with your current code

Link to comment
Share on other sites

uh guys, PFMaBiSmAd got it right, the point of these two lines of code is to send post data and only process that postdata if the get variable specified in the action attribute exists.  End of story.  You're not "confusing" the server at all.

 

You're the first one to bring up confusing the server, so I'm not sure what you're talking about.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.