Jump to content

Adding php code to javascript onclick event


andrew_ww

Recommended Posts

Hello,

 

I'm trying to convert this:

<a href="<?php echo $logout; ?>" class="style1">Log out</a>

 

so that it works in the onclick event, I've tried this - but it does not work:

 

<input type="BUTTON" class="style2" onClick="<?php echo $logout; ?>" value="Log Out">

 

the actual logout code is this:

 

// Logout link
$logout = $_SERVER['PHP_SELF']."?begone=true";
// If user chooses to logout unset session and redirect
if(isset($_REQUEST['begone']) && $_REQUEST['begone'] == true) {
$_SESSION['authenticated'] = NULL;
unset($_SESSION['authenticated']);
header("location: ../home.php?notification=loggedout");
}

 

Any help appreciated.

Archived

This topic is now archived and is closed to further replies.

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