Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am using a PHP variable called LeagueLink. When the user is not logged in I want the variable to read the text (Already have a league...) followed by a link to a popup window. So far it is displaying correctly except when I click on the link nothing happens. I think I just have a syntax error from mixing so much PHP and JS, but I can't figure out where. Please help make the popup window link work if you can...

<?php 
 // this starts the session 
 session_start();
 $_SESSION['userid'];
 $message = "";
 if ($_SESSION['userid'] == "") {
    $message = "You must create an account or sign in to play!";
    $LeagueLink = "Already have a league...<a href='JavaScript:newPopup(\"http://www.yourfantasyfootballreality.com/signin.php\");' class='two'>Sign In</a>";
 } else {
    $message = "Hello, " .$_SESSION['userid'] . " make your picks!";
 }

 ?> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <script type="text/javascript" src="js/jquery-1.2.6.min.js"></script>
        <script type="text/javascript" src="js/jquery-easing-1.3.pack.js"></script>
        <script type="text/javascript" src="js/jquery-easing-compatibility.1.2.pack.js"></script>
        <script type="text/javascript" src="js/coda-slider.1.1.1.pack.js"></script>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="icon" href="http://www.indiana.edu/favicon.ico" />
        <title>YourFantasyFootballReality</title>
        <link rel="stylesheet" type="text/css" href="mystyle.css" />

    </head>
        <body>
            <?=$message?>
            <?=$LeagueLink?>
            <?=$ActionLink?>
        </body>
</html>
share|improve this question
    
The year is 2012. Please abandon popups now. –  Jezen Thomas Jul 21 '12 at 23:58
    
Why are you telling me this? –  John Doe Jul 21 '12 at 23:59
    
Because I'd like for your work to be as good as it can be! :) As a side note, what's the thinking behind the lines between the body tags? That doesn't look like valid PHP to me. –  Jezen Thomas Jul 22 '12 at 0:03
    
what lines between the body tags?? –  John Doe Jul 22 '12 at 0:10
    
<?=$message?> <?=$LeagueLink?> <?=$ActionLink?> –  Jezen Thomas Jul 22 '12 at 0:11

1 Answer 1

up vote 1 down vote accepted

JavaScript:newPopup is a function that needs to be defined.

I think what you are looking for is the following: You don't need javascript to open the page in a new window. Just set the target property of the link to _blank.

$LeagueLink = "Already have a league...<a href='http://www.yourfantasyfootballreality.com/signin.php' target='_blank' class='two'>Sign In</a>";

EDIT: If you want it popping up, rather than opening in a new tab, you can resize it immediately after it is spawned. Add the following to your javascript.

function newPopup()
{
var url='http://www.yourfantasyfootballreality.com/signin.php';
windowProperties = "toolbar=no,menubar=no,scrollbars=no,statusbar=no,height=500px,width=500px,left=50%,top=50%";
popWin = window.open(url,'newWin',windowProperties);
}

and keep your PHP the same as before.

share|improve this answer
    
Thank you! But I want it to be a popup. Do you know how I would do that... –  John Doe Jul 21 '12 at 23:34
    
This is a popup. Do you want it to be smaller in size? –  Anirudh Ramanathan Jul 21 '12 at 23:35
    
I'm sorry. I mean a popup window. Your solution just creates another tab... –  John Doe Jul 21 '12 at 23:36
    
Do you know how to do this? –  John Doe Jul 21 '12 at 23:38
    
You can use jQuery UI to create pop-ups. –  Tarik Jul 21 '12 at 23:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.