Jump to content

Insert a variable into a URL for $_GET later


Nightmareinhell

Recommended Posts

Hello! I was wondering if this could be done... I want to take a variable, and insert it into a URL for a $_GET on a different page?  Basically Its a member website, and I want the admin to be able to "accept" or "deny" the application... So i have a page that displays all the applications, and I want it to take him to a different page with all the user's information in detail.  Right now it only displays their name, but when the admin presses the link, it takes them to a more detailed page about the applicant, where they can then "accept" or "deny" the application....

 

Here is what i got so far...

$character_name = "Nightmareinhell";
<a href="admin_evaluate.php?name=$character_name">$character_name</a>

 

Here is the error I get from the code above

Parse error: syntax error, unexpected T_STRING in C:\wamp\www\admin_acceptapply.php

 

Thanks to any help!!!!

Link to comment
Share on other sites

You're just throwing a string in there (<a href="admin_evaluate.php?name=$character_name">$character_name</a>) after you assign the value to $character_name. That's why you're getting the error. What are you trying to do with that string? Echo it?

Link to comment
Share on other sites

Sorry I did not put enough information down :P Yes, Its in a loop that displays all the application names (for the purpose of this post.. i just threw in $character_name = "Nightmareinhell";, it really gets its value from a database)

 

But... Here is more of my code i guess you could say...

 

$character_name = "Nightmareinhell"
$name = "<tr>
				<td><a href="admin_evaluate.php?name=$character_name">$character_name</a></td>
			</tr>";
	echo $name;

 

I want it to where when you click on that link, I'm able to grab name by using:

$character_name = $_GET['name'];

 

Thanks!!

Link to comment
Share on other sites

You're trying to use unescaped double quotes within a double quoted string. When using quotes of the same type that enclose the string, they need to be escaped with backslashes as below.

 

$character_name = "Nightmareinhell"
$name = "<tr>
                     <td><a href=\"admin_evaluate.php?name=$character_name\">$character_name</a></td>
            </tr>";
      echo $name;

Link to comment
Share on other sites

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.