5eeker
5eeker

Reputation: 1027

PHP Get method not taking

I have used Get method in a form to fetch the name variable from a page, but it's only fetching the firstname and leaving the part after space. I want to select the complete field along with spaces.

<a href=view_contsheet.php?Patientid=<?php echo $_GET["id"]; ?>&Patientname=<?php echo $_GET["Patientname"];?>>View Visits</a>

In this link, only the first name is getting passed. How can I concat the complete field?

Upvotes: 0

Views: 134

Answers (3)

Praveen kalal
Praveen kalal

Reputation: 2129

try this code

<a href="view_contsheet.php?Patientid=<?php echo $_GET["id"]; ?>&Patientname=<?php echo urlencode($_GET["Patientname"]);?>">View Visits</a>

and at the next page use urldecode

Upvotes: 0

bestprogrammerintheworld
bestprogrammerintheworld

Reputation: 5520

As I see it you shouldn't send the patient's name at all in the url.

Instead of

<a href=view_contsheet.php?Patientid=<?php echo $_GET["id"];?>&Patientname=<?php echo $_GET["Patientname"];?>>View Visits</a>

do

<a href="view_contsheet.php?Patientid=<?php echo $_GET["id"]; ?>">View Visits</a>

and in view_contsheet.php you fetch the name based on the Patientid

$id = $_GET['Patientid'];
"select Patientname FROM patients WHERE Id=$id"....

Upvotes: 0

Arnelle Balane
Arnelle Balane

Reputation: 5487

This might be because spaces are not allowed in URLs.

<a href="view_contsheet.php?Patientid=<?php echo $_GET["id"]; ?>&Patientname=<?php echo urlencode($_GET["Patientname"]);?>">View Visits</a>

urlencode() will make the parameter url-friendly. There is also a urldecode() function, which does the reverse of urlencode()

Upvotes: 3

Related Questions