Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 08-23-2010, 01:55 AM PHP Code Help
B00
Junior Talker

Posts: 4
Trades: 0
Hello, I'm new to PHP.

I wanted to know about a specific section of PHP about PHP $_GET.

I am trying to link the index.php to index.php?page=downfile&area=1&file_id=1

The page is about an article with a download button.

Do you guys have any idea to code this?

Thanks in advance.

Last edited by B00; 08-23-2010 at 02:00 AM..
B00 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-23-2010, 01:59 AM Re: PHP Code Help
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Are you asking how to retrieve url parameters?
PHP Code:
//index.php?page=downfile&area=1&file_id=1

$page $_GET['page']; //downfile in this case
$area $_GET['area']; //1
$file_id $_GET['file_id']; //1 
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 08-23-2010, 02:02 AM Re: PHP Code Help
B00
Junior Talker

Posts: 4
Trades: 0
Maybe, so what do i do to get the page to load? Like do I have to create file for

index.php?page=downfile&area=1&file_id=1
B00 is offline
Reply With Quote
View Public Profile
 
Old 08-23-2010, 02:06 AM Re: PHP Code Help
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
The file is index.php after thing afterward is the query string.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 08-23-2010, 07:28 AM Re: PHP Code Help
Ultra Talker

Posts: 310
Trades: 0
Quote:
Originally Posted by B00 View Post
Maybe, so what do i do to get the page to load? Like do I have to create file for

index.php?page=downfile&area=1&file_id=1
If you're trying to use index.php for both display the article and file downloads, then link download button to index.php?page=downfile&area=1&file_id=1. In the index.php file check for query parametersat the top, if the correct values are present then let the user download the file, otherwise display the article.
dman_2007 is offline
Reply With Quote
View Public Profile
 
Old 08-23-2010, 03:58 PM Re: PHP Code Help
B00
Junior Talker

Posts: 4
Trades: 0
Alright, Im getting some stuff going here. But i wanted to know what to do when i link the page like i have:

<a href=index.php?page=downfile&area=1&file_id=1>Some text</a>

Can u explain to me how to do it step by step? Cause right now its showing nothing right now. Just the same index.
B00 is offline
Reply With Quote
View Public Profile
 
Old 08-23-2010, 04:02 PM Re: PHP Code Help
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
The only way a query string is going to make a difference in the output of your script is if you explicitly code it to do so. Here is a trivial example:
PHP Code:
//index.php
if(isset($_GET['page']))
     echo 
'Page: ' $_GET['page'];
else
     echo 
'No Page'
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 08-23-2010, 04:21 PM Re: PHP Code Help
B00
Junior Talker

Posts: 4
Trades: 0
Where do I insert that code? On my index.php?
B00 is offline
Reply With Quote
View Public Profile
 
Old 08-25-2010, 09:46 AM Re: PHP Code Help
Banned

Posts: 408
Name: mushget
Trades: 0
The built-in $_GET function is used to collect values from a form sent with method="get".
Information sent from a form with the GET method is visible to everyone (it will be displayed in the browser's address bar) and has limits on the amount of information to send (max. 100 characters).
Example

<form action="welcome.php" method="get">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
When the user clicks the "Submit" button, the URL sent to the server could look something like this:
http://www.w3schools.com/welcome.php?fname=Peter&age=37
The "welcome.php" file can now use the $_GET function to collect form data (the names of the form fields will automatically be the keys in the $_GET array):
Welcome <?php echo $_GET["fname"]; ?>.<br />
You are <?php echo $_GET["age"]; ?> years old!
mushget is offline
Reply With Quote
View Public Profile Visit mushget's homepage!
 
Reply     « Reply to PHP Code Help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.46490 seconds with 12 queries