php - form submit inside navigation menu -


what need this

my menu

my php code is:

class logout{     public function __construct(){         session_unset();         session_destroy();         session_write_close();         setcookie(session_name(),'',0,'/');         session_regenerate_id(true);     }   } if(!empty($_post['logout'])){     $object=new logout(); } 

for i'm using html code:

<ul id="navlist">       <li><a href="index.php">home</a></li>       <li><a href="dates.php">dates</a></li>       <li><a href="candidate.php">candidates</a></li>       <li><a href="database.php">database</a></li>       <li><a href="password.php">change password</a></li>       <li><a href='logout.php'>log out</a></li> </ul> 

for logout need javascript form submit anchor i've read not secure.

if this:

<li><a href=''><form method="post"><input type='submit' value='log out' name='logout' style="border:0px;" /></form></a></li> 

i'm getting this:

bad menu

how solve problem (do i've use javascript how submit form?)

you can via ajax if have jquery loaded. way can keep nav styling well.

<li><a href="#" class="log-out">log out</a></li>  $('.log-out').click(function() {    $.post('logout.php'); }); 

learn more ajaxs shorthand $.post() or $.ajax()


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -