Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Silly question! When you use post / get, where does the data actually go?

Featured Replies

Please excuse the silly question!

 

I've been learning javascript.

 

I know how to make a form, well good enough to get a decent mark for my code at college anyway.

 

But back in the real world, I've realised I have no idea where the code goes! In the assignment we did at college I believe the data was going off to my tutor's server. However we just learnt how to build a form, and not how to retrieve the data.

 

I know the code is sent in the header or appended to the URL - but then what? (I can't ask my tutors, we're on holiday).

 

Or to put it another way, if you looked at some code that someone else had built could you tell where it was going to?

 

And does the data usually go into a database, or would / could you set it up to be emailed to an email account perhaps?

 

Sorry for the dumb ass question, I'd be really grateful if someone could enlighten me, thanks! :)

Edited by Becca B

I'll give some demo code to help explain:

 

<form action="http://somewebsite.com/form-process.php" method="post">
<input type="text" name="name" value="" />
<input type="text" name="email" value="" />
<input type="submit" value="Send" />
</form>

 

For that code above, everything is being posted to a script at somewebsite.com/form-process.php. PHP is generally the language used to process forms (there are many, many alternatives). Posted data does not go into the address bar, but if we were to change the method to "get", the request sent would be:

 

http://somewebsite.com/form-process.php?name=whatever&email=whatever

 

To look at the PHP side of things...

 

To start with, we'll use method="post" in the form to POST data (you would set the action="THIS BIT" to point to this following script):

 

<?php
if (!empty($_POST)){
	echo 'The $_POST array:<br />';
	print_r($_POST);
	echo "<br /><br />And to loop through them all:<br /><ul>";

	foreach($_POST as $key => $val){
	    echo "<li>$key: $val</li>";
	}

	echo "</ul>";
}
?>

 

If we were using method="get" we would simply switch $_POST to $_GET. You can also use $_REQUEST which can be used to get both posted and 'get' data, but which also includes the PHPSESSID variable which is a unique session cookie.

 

You can of course email the information sent - you can literally do whatever you want with it.

Edited by andyl

Great explanation, well done, Andy. +1

  • Author

Thanks for the response, I appreciate it.

 

I think I get it now ... :)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.