Jump to content

Problem in passing data with embedded link


Go to solution Solved by eaglehopes,

Recommended Posts

Hi to all !

I have a web page whose main page is index.php I try to use passing data inside embedded URLs : my code is below :

<!DOCTYPE html>
<html>
 <body class="background" >
   <div>
			<a class="button" href="./index.php?page=home" target="_self">Home</a>
			<a class="button" href="./index.php?page=about" target="_self">About</a>
			<a class="button" href="./index.php?page=blog"  target="_self">Blog</a>
   </div>
   <div>
      <?php 
			include 'db.inc';
			
			echo "page selected is ". $page ."\n";
			// if user request blogs- then show blog menu here
			if ( strcmp($page,"blog")==0)  
			{	 // get new menu from file
				echo "YEKEKE ". $page ."is blog";
					if( include ('./pages/blog/categories/categories.php') == TRUE ) {
						// do nothing
					} else {
						echo "Page Load error...";
					}

			} else {

				echo "try out";

			}
			console.log($page."is blog");
		?>
   </div>
  </body>
</html>

However, it does not work since I could not get $page variable correctly, I get $page as blank variable. Why, where is my mistake? Any help is appreciated.

Edit : I try to do that

1. user click link in index.php page

2. get the new page inside index.php with sended value of the $page variable...

Edited by eaglehopes

There used to be a time, long ago, where $page would be created automatically. If whatever resource you're learning from expects that to be the case and doesn't use $_GET/POST then you need to find another resource to learn from.

16 hours ago, requinix said:

There used to be a time, long ago, where $page would be created automatically. If whatever resource you're learning from expects that to be the case and doesn't use $_GET/POST then you need to find another resource to learn from.

Thanks requinix ! It happens exactly as you said : my resource is a book and it says that "PHP initialize $page variable automatically". It also says that use $HTTP_GET_VARS["varname"] to get the sended variable !  So I had to research extra documents to find that all of them depreceated. Time to change resource as you said :)

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.