Jump to content

get and post with the same variable


divinedesigns1
 Share

Recommended Posts

hey, i have a question, is it possible to have a variable with both post and get? like say i have a variable name whitechocolate and it have a method of both get and post like this $whitechocolate = $_GET['chocolate'];$whitechocolate = $_POST['chocolate]; buttt they do different things, one get/delete the chocolate whiles the other one input/update the chocolate would that cause any problem? or should i just change that?

Link to comment
Share on other sites

yes it is possible,you can use like that. when you use $_RQUEST it has some conflicts cause it uses get,post even cookie data. for this reason it is best to avoid $_RQUEST and use specifically $_GET,$_POST,$_COOKIE

Link to comment
Share on other sites

well the get grab the old data and the post input the new data, so yeah it do

Link to comment
Share on other sites

Your page access has to be either a GET or a POST. I think you should test for which it is before going for get/post data.
it work with both the get and post super gobal.
GET and POST are data sent from the client. It's all new data.
yup yup
Link to comment
Share on other sites

Guest So Called

Well AFAIK you will $_GET populated only if it's a GET access, and will get $_POST populated only if it's a POST access. I could be wrong... Maybe something like:

if (isset($_POST)) {	// process post code here}else {	// process get code herre}

Link to comment
Share on other sites

ok i didnt know you can have a mode in the action also

<form method="post" action="process.php?mode=submit">
how would that work? sorry for the late reply, only got access to the forum this morning Edited by DDs1
Link to comment
Share on other sites

Well AFAIK you will $_GET populated only if it's a GET access, and will get $_POST populated only if it's a POST access. I could be wrong... Maybe something like:
if (isset($_POST)) {	// process post code here}else {	// process get code herre}

but you can also use both at on the same page by defining what both of them will be doing
Link to comment
Share on other sites

how would that work?
The query string of the url will evaluate $_GET and the input fields of the form will be available in $_POST. in the receiving page you can work with them both.
Link to comment
Share on other sites

it's not a "mode" as in something that is part of PHP or HTML; it's just part of the url, forming part a query string. "Mode" is only meaningful to the developer of the context of this application.

Edited by thescientist
Link to comment
Share on other sites

it's not a "mode" as in something that is part of PHP or HTML; it's just part of the url, forming part a query string. "Mode" is only meaningful to the developer of the context of this application.
oh ok gotcha
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...