$name='joseph john mathew';
$urlPgN ="<a href=author_stories.php?pgNo={pgNo}&name=$name style='text-decoration:none;color:#666; padding:0 2px 0 2px; '>{pgTxt}</a>";
I'm getting localhost/rose/author_stories.php?pgNo=2&name=joseph
only. How can I do it so I get the full name in the URL?
By using urlencode and urldecode
$name=urlencode('joseph john mathew');
$urlPgN ="<a href=\"author_stories.php?pgNo={pgNo}&name=$name\" style=\"text-decoration:none;color:#666; padding:0 2px 0 2px;\">{pgTxt}</a>";
And to fetch
$name = urldecode($_GET['name']);
While you should use urlencode
, you don't need to. The real problem is due to the fact that you don't have quotes around the href
attribute:
$urlPgN ="<a href='author_stories.php?pgNo={pgNo}&name=$name'
Using urlencode($name)
can be done too and is more technically correct.
Do not use urldecode
on $_GET
/$_POST
. This is done automatically by PHP.
use urldecode and you are missing quotes for href attributes.
$urlPgN ="<a href='".urldecode('author_stories.php?pgNo='.$pgNo.'&name='.$name)."' style='text-decoration:none;color:#666; padding:0 2px 0 2px; '>$pgTxt</a>";