TomTees Posted September 19, 2010 Share Posted September 19, 2010 Would someone please help me understand how data is sent from an HTML form to the server? If I have a simple HTML form that appears on someone's computer, how is the data sent to the server that PHP is on? TomTees Quote Link to comment https://forums.phpfreaks.com/topic/213824-need-help-understanding-how-data-is-sent-from-a-form/ Share on other sites More sharing options...
PaulRyan Posted September 19, 2010 Share Posted September 19, 2010 Hey TomTees, I see you are still on this Checkout here, it may help you understand a little more. Link: http://bytes.com/topic/php/insights/664241-using-html-forms-pass-data-php Regards, Paul. Quote Link to comment https://forums.phpfreaks.com/topic/213824-need-help-understanding-how-data-is-sent-from-a-form/#findComment-1112853 Share on other sites More sharing options...
TomTees Posted September 19, 2010 Author Share Posted September 19, 2010 Hey TomTees, I see you are still on this Yep, I'm still in "dumb" mode this weekend!! Checkout here, it may help you understand a little more. Link: http://bytes.com/topic/php/insights/664241-using-html-forms-pass-data-php Regards, Paul. Thanks, but I have some questions... (Sorry for being so obtuse, I'm so damn tired of spending weeks reading books only to forget what I read because I never have enough time to implement what I just learned. I need to take a more "ask then do" approach until I get some momentum going...) 1.) So when you submit data from an HTML form, it is stored in an array called GET or POST depending on what you specified in form? 2.) And the GET or POST array is a "global" variable? (Sounds scary and insecure upfront?!) 3.) And what pages can see these global arrays? 4.) When you submit the HTML form, the data is sent in the URL with GET, right? 5.) When you submit the HTML form, the data is secretly with POST, right? Where is it again exactly? 6.) Data is sent to the "action" page you designated? 7.) So data is sent to the "action" page, or you are just routed there or what? 8.) If I was on some other non-action page, could I see what is in GET or POST? (If so, what stops people from hi-jacking your data off the Internet?!) 9.) Can I assigned data to variables first in my HTML form, or must they be in the GET/POST arrays before they are submitted? 10.) Can my php code in the "action" page just echo what is in the GET/POST arrays? 11.) Can I assign values in the GET/POST arrays to a variable in my local "action" page? 12.) How do I avoid that ugly "undefined variable error" that I didn't understand last night? Hope I don't get yelled at for all of these questions, but I am trying to *learn* how all this jazz works again, and it is related all to my original post. Also, this is uch quicker than reading 3-4 chapters in my dusty PHP books!) What I wouldn't give to be 20 again with a more elastic brain that learns quicker and retains better?! Thanks, TomTees Quote Link to comment https://forums.phpfreaks.com/topic/213824-need-help-understanding-how-data-is-sent-from-a-form/#findComment-1112859 Share on other sites More sharing options...
TomTees Posted September 19, 2010 Author Share Posted September 19, 2010 P.S. I think where I am getting hung up is that examples people posted online and from my dusty PHP book, because they just echo what you submitted in the form on the same page?! The context of my original question is to get understand how you pass data entered into an HTML form on the user's computer to a PHP page (i.e. class) on a webserver and then pass that data to another PHP pgae (i.e. another class) on the webserver... This whole Internet thing and how data is passed from user to server is still kinda foreign to me. TomTees Quote Link to comment https://forums.phpfreaks.com/topic/213824-need-help-understanding-how-data-is-sent-from-a-form/#findComment-1112862 Share on other sites More sharing options...
Pikachu2000 Posted September 19, 2010 Share Posted September 19, 2010 The same page, or a different page, the mechanics are the same; the data is sent to the server. PHP is a server-side language, therefore for any data manipulation to happen it needs to be passed to the server, handled, and then returned to the client. Quote Link to comment https://forums.phpfreaks.com/topic/213824-need-help-understanding-how-data-is-sent-from-a-form/#findComment-1112864 Share on other sites More sharing options...
jcbones Posted September 19, 2010 Share Posted September 19, 2010 POST is sent in the header of the requested page. Which is in the action attribute of the form. To pass the POST variables to further pages, you must set those variables into either a COOKIE, or a SESSION variable. In a nutshell, when you submit a form ( or click a link ), your computer sends a data packet to the server with the requested page's info. If you clicked on a form submit button ( with action="post" ), it will also include a POST array, containing the values of the inputs, with the input names as the KEY in the POST array. Quote Link to comment https://forums.phpfreaks.com/topic/213824-need-help-understanding-how-data-is-sent-from-a-form/#findComment-1112898 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.