You are here: Re: PHP within javascript « PHP Programming Language « IT news, forums, messages
Re: PHP within javascript

Posted by Michael Fesser on 08/27/07 17:42

..oO(Morlaath@gmail.com)

>Anytime I embed php within javascript with the <?php ?> tags the php
>executes as soon as the page is loaded.

Sure, because that's how it works. PHP is server-side. When the page
arrives in the browser, the execution of the PHP script is finished
already.

>So for instance if I have
>something like the following.
>
>//Javascripts
>function foo() {
> <?php session_destroy(); ?>
>}
>
><input type="button" value="logout" onclick="foo();"/>
>
>The 'session_destyoy()" is called as soon as the page is loaded,
>instead of when you click on the button.

Your button click would have to invoke another server-side script to
kill the session, something like <http://example.com/logout.php>. No
need for JavaScript here.

Micha

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация