/    Sign up×
Community /Pin to ProfileBookmark

Get Method reading from a URL?

I want to use the GET Method for reading data from a URL. If you have a URL:

[CODE]http://www.site.com/name?data=123[/CODE]

First, how does a Browser execute the site when the data number change?

Second, how do you set up PHP in your program to read the data:

[CODE]$data = $_GET(‘data’);[/CODE]

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@spufiFeb 27.2012 — Get should be:

<i>
</i>$data = $_GET['data'];


http://php.net/manual/en/reserved.variables.get.php

Nothing really happens with the numbers if they are changed unless you specifically code for handling the data value.
Copy linkTweet thisAlerts:
@PhilosophaieauthorFeb 27.2012 — How do I get the Get Method url to read and execute with the "?data=#" on the end? The number varies.

url = http://www.site.com/name.htm?data=123

The Browser will not execute the above url. How do I get the Browser to run it.
Copy linkTweet thisAlerts:
@spufiFeb 27.2012 — url = http://www.site.com/name.htm?data=123[/QUOTE]

Needs to be a .php type file. You have it as a HTML file. FYI, the browser isn't doing anything really. It's the server that sees a HTML file and doesn't process the PHP. If the server sees a PHP file, it will execute the PHP code.
Copy linkTweet thisAlerts:
@PhilosophaieauthorFeb 27.2012 — Made a php file of my htm file. I used:

http://www.site.com/name.php?data=27

Seems to be reading ok,

$data=$__GET['data'];

echo $data=27

I am having a "SESSION_START()" error:

Cannot send session cache limiter - headers already sent [/QUOTE]

I am not dealing with headers in this example. Here is a sample:

session_start();

$_SESSION['mo'] = $mo;

session_write_close();[/QUOTE]
Copy linkTweet thisAlerts:
@spufiFeb 27.2012 — Sessions need to start even before the <!DOCTYPE> markup is used.
Copy linkTweet thisAlerts:
@PhilosophaieauthorFeb 27.2012 — Yes before <!DOCTYPE>. <?php starts the first line and it is in that group.
Copy linkTweet thisAlerts:
@hyperionXSFeb 27.2012 — It means you get an error prior to session_start.

Can you copy lines prior to session_start();

Also put session_start in the first line.
Copy linkTweet thisAlerts:
@ZABIFeb 28.2012 — put session_start(); before every output function (echo, print, print_r) or any HTML element. session_start(); can be very first statement.

You can also use @session_start(); to suppress errors in case you don't want your visitors see that error message
Copy linkTweet thisAlerts:
@criterion9Feb 28.2012 — put session_start(); before every output function (echo, print, print_r) or any HTML element. session_start(); can be very first statement.

You can also use @session_start(); to suppress errors in case you don't want your visitors see that error message[/QUOTE]


I recommend turning off displaying errors within your php.ini file. You want to see errors during development so you don't introduce issues into your production site.
×

Success!

Help @Philosophaie spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...