Run a <a href> link from PHP - Slight Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
davidhopkins
Forum Commoner
Posts: 41
Joined: Thu Jun 10, 2010 7:52 am

Run a <a href> link from PHP - Slight Problem

Post by davidhopkins »

Hello All.

I am building a website that needs to make use of some sort of greybox, to show content in a popup basically. I have found one solution that looks really good and I am keen on using, however i am struggling to get it working with PHP.

Basically the greybox i plan to use requires the following link in order to work

<a rel="gb_page_center[500, 500]" title="Google" href="http://google.com/">Launch google.com in a 500x500 center window</a>

However the way my program works, is as following:
I have a form with four buttons, and a PHP sciript that is called when the buttons are clicked -

Code: Select all

<?php
if ($_POST['Que'])
{
    echo "Question<br>";
	echo $_POST['JobID'];
}
else if ($_POST['Can']) {
	echo "Candidate<br>";
	echo $_POST['JobID'];
}
else if ($_POST['Rec']) {
	echo "Recruiter<br>";
	echo $_POST['JobID'];
}
else if ($_POST['Del']) {
	echo "Delete<br>";
	echo $_POST['JobID'];
}

?>
What i want to do is when the $_POST['Que'] if statement is a success i need a popup to be shown, using this greybox so i need PHP to initiate the link really.

The PHP code has to think that the user has pressed the following link
<a rel="gb_page_center[500, 500]" title="Google" href="http://google.com/">Launch google.com in a 500x500 center window</a>

Im not sure if this is possible, or if i have explained this well enough, i havent posted the link to the greybox because im not sure if im allowed

ANy help would be great

Thanks
dgreenhouse
Forum Newbie
Posts: 20
Joined: Tue Mar 10, 2009 5:13 am

Re: Run a <a href> link from PHP - Slight Problem

Post by dgreenhouse »

I'm not sure how your greybox works, but they typically are initiated with JavaScript.

If you want your greybox to be initiated via PHP, you'll have to go to a page with the greybox enabled and appropriate page loaded.

I assume.

I think you'll need to provide some additional information; particularly regarding the greybox your using.
davidhopkins
Forum Commoner
Posts: 41
Joined: Thu Jun 10, 2010 7:52 am

Re: Run a <a href> link from PHP - Slight Problem

Post by davidhopkins »

Hey, Thanks for your reply.

The greybox i am using is this - http://orangoo.com/labs/GreyBox/

Its kinda difficult for me to figure out because you can load anypage by using this link <a rel="gb_page_center[500, 500]" title="Google" href="http://google.com/">Launch google.com in a 500x500 center window</a>

So I could change the http://google.com to any page i want, and that page gets loaded inside the greybox.

My problem is implementing this inside a PHP script. Im not sure if im gonna be able to do it.

Thanks David
dgreenhouse
Forum Newbie
Posts: 20
Joined: Tue Mar 10, 2009 5:13 am

Re: Run a <a href> link from PHP - Slight Problem

Post by dgreenhouse »

JavaScript hooks any links found on the page when the page loads.
It looks for any links with a rel attribute of {gb_page_center[500, 500] in this case}.
I didn't look at the docs for this greybox, but I'm sure there are a number of rel attributes it will look for.

The only way to manage this with php is to place the url in the link you want to user to visit before the page is sent to the browser.

You could create a script on your server and add its url to the link with an argument.
i.e goto_page.php?arg=something

goto_page.php could then redirect to pages based on the value of $_GET['arg'].
Post Reply