Problem with php get function?

I want to pass this topic parameter to another page,

ps page load using jquery?

URL:

 http://localhost/final/home.php#page2?topic=jquery 

Now, I want to repeat the topic on page # page2

 <h3 class="timeline"><?php echo $_GET["topic"]; ?> </h3> 

but this is deosnt echo, any solutions, sorry for new questions :))

load_page.php

 <?php if(!$_POST['page']) die("0"); $page = (int)$_POST['page']; if(file_exists('pages/page_'.$page.'.php')) include('pages/page_'.$page.'.php'); // ie page_2.php else echo 'There is no such page!'; ?> 
+4
source share
4 answers

remove php from dataType and read it read this about data types for ajax requests

+1
source

Your URL should be like this:

 http://localhost/final/home.php?topic=jquery#page2 

Everything after the hash ( # ) is not sent by the browser, it is pure for the browser, for example. scrolling to the right place, a way to make AJAX history, etc., but it is not sent to the request, now all that your server receives:

 http://localhost/final/home.php 

This explains why _GET["topic"] empty.

+7
source

For practical effects, the URL ends with # . Everything else is not even sent to the server.

You probably want:

 http://localhost/final/home.php?topic=jquery#page2 
0
source

Just use PHP parse_url to do something like this:

 $url = 'http://username: password@hostname /path?arg=value#anchor'; //Replace the URL in your case with "http://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"] print_r(parse_url($url)); echo parse_url($url, PHP_URL_PATH) 

What will return:

 Array ( [scheme] => http [host] => hostname [user] => username [pass] => password [path] => /path [query] => arg=value [fragment] => anchor ) /path 

In your case, it will be more like:

 Array ( [scheme] => http [host] => localhost [path] => /final/home.php [query] => topic=jquery [fragment] => page2 ) 
0
source

All Articles