开发者

Use a javascript function in php

I have a nav bar on my site that has dynamic links. When the user is logged out, I want these links to say "Register | Log in" and when they are signed in, I want those same links to change to "$userName | Account". I have a script to handle this, but there is one problem.

When the user is signed out, I want the "Register" link to open a popup div with the registration page on it, instead of forwarding them to a different page. The only problem is, the way I am handling this is in a link like

<a href="#" onClick="popup('popUpDiv')">Register</a>

But I need to call this in a php script.

Any Help is appreciated.

This is from the php script.

 if (!isset($_COOKIE['idCookie'])) {
 $logOptions = ' <a href="http://' . $dyn_www . '/register.php">Register</a>
 &nbsp;&nbsp; | &nbsp;&nbsp; 
 <a href="http://' . $dyn_www . '/login.php">Log In</a>';

}

But instead of having the whole 开发者_如何学Cregister.php, i just want it to go to

<a href="#" onClick="popup('popUpDiv')">Register</a>


I think what you want to use if you are looking to do it in php is this ...

header('location: http://yoururl.com/page.php')

Sorry if I don't understand the question completely. Posting some code would help.

Hope this helps :)


Simply do a server-side check around the HTML you want to output. PHP is parser based.


Try something like this :

<?php
if ($ID = '') {
echo "<script language=javascript>alert('Please enter a valid username.')</script>";
}
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜