divinedesigns1 Posted June 19, 2012 Share Posted June 19, 2012 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 More sharing options...
birbal Posted June 19, 2012 Share Posted June 19, 2012 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 More sharing options...
divinedesigns1 Posted June 19, 2012 Author Share Posted June 19, 2012 ok thanks birbal Link to comment Share on other sites More sharing options...
Ingolme Posted June 19, 2012 Share Posted June 19, 2012 What is the POST and GET have different values? I can't see a good reason to access both at the same time. Link to comment Share on other sites More sharing options...
divinedesigns1 Posted June 19, 2012 Author Share Posted June 19, 2012 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 More sharing options...
Guest So Called Posted June 19, 2012 Share Posted June 19, 2012 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. Link to comment Share on other sites More sharing options...
Ingolme Posted June 19, 2012 Share Posted June 19, 2012 GET and POST are data sent from the client. It's all new data. Link to comment Share on other sites More sharing options...
divinedesigns1 Posted June 19, 2012 Author Share Posted June 19, 2012 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 More sharing options...
Guest So Called Posted June 19, 2012 Share Posted June 19, 2012 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 More sharing options...
justsomeguy Posted June 19, 2012 Share Posted June 19, 2012 $_GET will always contain variables passed in the URL, regardless of the request type. e.g.: <form method="post" action="process.php?mode=submit"> Link to comment Share on other sites More sharing options...
divinedesigns1 Posted June 21, 2012 Author Share Posted June 21, 2012 (edited) 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 June 21, 2012 by DDs1 Link to comment Share on other sites More sharing options...
divinedesigns1 Posted June 21, 2012 Author Share Posted June 21, 2012 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 More sharing options...
birbal Posted June 21, 2012 Share Posted June 21, 2012 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 More sharing options...
thescientist Posted June 21, 2012 Share Posted June 21, 2012 (edited) 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 June 21, 2012 by thescientist Link to comment Share on other sites More sharing options...
divinedesigns1 Posted June 22, 2012 Author Share Posted June 22, 2012 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now