0
$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?

4

3 回答 3

2

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.

于 2013-01-30T07:26:01.293 回答
0

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']);
于 2013-01-30T07:23:57.080 回答
0

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>";

ref: http://php.net/manual/en/function.urlencode.php

于 2013-01-30T07:30:39.733 回答