Search code examples
phphref

How to Pass a value via href - PHP


Am passing a value using href tag

In first page Href tag used as

echo "<a href=view_exp.php?compna=",$compname,">$compname</a>";

In the Second page used

$compname = $_GET['compna']; 

To receive the Compna values are pass but only the first word is passed remaining words are skipped.

Compname as " Chiti Technologies Ltd " When I pass the value I receive onlt "Chiti"


Solution

  • The reason you're only getting the first word of the company name is that the company name contains blanks. You need to encode the name.

    echo "<a href=view_exp.php?compna=",urlencode($compname),">$compname</a>";