Jump to content

Recommended Posts

ok, I have come a long way on my own with php.... that said... I don't even know what to call it to look this part up... First, what is it called when you use something like "index.php?data=something" to handle information? Second, what do you use to process data from it... for example data from a form is

$data = $_POST['data']

but what would I use with that... The first question should point me in the right direction, but if anyone wants to explain the whole thing for me, that'd be cool... I just need to know how to get it into a variable... Thanks

Link to comment
https://forums.phpfreaks.com/topic/55527-solved-help-with-phpdata/
Share on other sites

That would be called using the $_GET method.

 

Say you had the URL:

www.yoursite.com/index.php?data=12345

 

You could use this code to get the data:

$data = $_GET['data'];

 

Then if you printed that, like this:

echo $data;

 

That would print "12345". You could use this information the same way you would use POST information. The only difference is it is stored in the URL, and POST data is hidden. So be careful and not to use things in the URL that you don't want people to see, such as passwords and such.

When the URL is something like "index.php?data=something",

 

You can use the $_GET PHP predefined variable to collect data from the URL.

 

Example,

<?php

$data = $_GET['data'];

echo $data;

// Or store this somewhere

?>

 

The above script would display

something

on the web page.

 

If the form method used is POST you would not see the ?data=something part of the URL. It would just be index.php. You could use

$data = $_POST['data'] to capture the information posted by a form.

 

You would want to read more about form processing in PHP.

 

The below links provide more information

 

http://php.net/language.variables.predefined

http://www.w3schools.com/html/html_forms.asp

http://php.net/manual/en/tutorial.forms.php

 

 

 

 

 

 

 

 

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.