Jump to content

[SOLVED] Passing variable via URL


ainoy31

Recommended Posts

Hello-

 

I am trying to pass a few variables via the url.  Here is my script:

 

echo '<a href="'.$_SERVER['PHP_SELF'].'?pageNum=$nextPage&mode=Search&type=$Type">NEXT</a>';
echo '<a href="'.$_SERVER['PHP_SELF'].'?pageNum=$lastPage&mode=Search&type=$Type">LAST</a>';

 

The problem is that the value for $nextPage/$lastPage should be numeric and $Type should be a text.  I realized this when I try to do a $_GET call and they are empty.  Also, I can see it as empty when I put my mosue over the link as well.  I am doing something wrong here.  I have been coding since 6am today.  Thanks.  AM

Link to comment
https://forums.phpfreaks.com/topic/114457-solved-passing-variable-via-url/
Share on other sites

You can't have variables in a string that has single quotes. You have to either end the string and add the variable like LooieEng did, or use double quotes. You should also use urlencode on your variables to ensure it won't have any characters that mess up the variable list.

 

urlencode(variable);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.