Jump to content

Recommended Posts

Hi all.

 

The site I am working uses query strings in some of the admin functions. A list of users is displayed and the functions you can perform on their accounts are written as hyperlinks. I've already got one user registered "O'Neill" and although my queries work ok, the admin functions won't.

 

Here's the code:

 

echo "<a href='admin.php?changeuser=$changeuser&criteria=admin'>Change</a>";

 

The URL that is output is as follows:

 

admin.php?changeuser=o

 

I really want the URL to be:

 

admin.php?changeuser=o'neill&criteria=admin

 

Using addslashes simply adds a \ on the end of the URL.

 

Can anyone help me with this?

 

Thanks.

 

Kev

You should use urlencode when setting your url, eg

 

$changeuser = urlencode($changeuser);
echo "<a href='admin.php?changeuser=$changeuser&criteria=admin'>Change</a>";

 

Now when you use $_GET['changeuser'] use urldecode, eg

 

$changeuser = urldecode($_GET['changeuser']);

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.