Jump to content

Recommended Posts

Is it possible to pass a variable true a link??

 

like this

 

http://www.sitehere.com/index.php?page=delpic&id=16&path=upload/HID16_img1

 

Now i'm using the the include method, to load the content already.

 

this is the code i have

<a href="index.php?page=delpic&id=".$id."&path=".$n1[0].">

 

 

for some reason it's not working though...

 

I have this script

 

<?php

$page = $_GET['page'];
$page = ($page != '') ? $page : 'hfs' ;
$page .= '.php';
$page = preg_replace('%(?:\.\./)+%', '', $page);

if (!is_dir($page) && file_exists($page)) {
	if (!(@include($page))) {
		include '404.txt';
	}
}
else {
	echo 'File does not exist';
}
?>  

 

in my index.php to display a page. now when I try passing the url I just gave, it tell me 'file does not exist'

. I don't see what the problem is, if it is possible to pass them like that

 

What would be the purpose of doing this? I never

used $_GET. Just asking to learn, thanks.

 

Well I use them to pass variable to another page, where I don't have forms.like going to a person profile link. you get the id, and and pass that...and in the other page just use the ID to retrieve all the other info. It's the only way I know how to pass variables...

The purpose of $_GET is to grab the variables from the URL. I believe that PHP does not auto register variables by default configuration.

 

I have simply always used it as that is the way I learned. $_POST retrieves variables in the http header of the page, and $_GET retrieves variables passed in the URL

 

 

Passing variables via the link is possible. I know because I have a site that does that from page to page through-out the site. Not to mention that I fought with a small error with it for 5 hours yesterday.

 

Anyways, make sure that the argument $page actually contains some data by running some kind of debugging script on the page that is to receive the data. Secondly, consider that you might be passing data that contains a delimeter. If so, the you will need to do a str_replace() before you pass the variable and again to convert it back once it is received by the next page.

Secondly, consider that you might be passing data that contains a delimeter. If so, the you will need to do a str_replace() before you pass the variable and again to convert it back once it is received by the next page.

 

A delimeter?? Care to elaborate?..No idea what that is...

@dmIllithid  -- Did you finally get that solved?? :)

 

A delimeter is an & symbol in the url..

 

When you pass a var such as  page.php?this=that&something=somethingelse the & is the delimiter. It separates your variables in your URL. Was trying to help dmIllithid yesterday with it.

 

Hope this helps

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.