Re: <img src .....> problem in onclick

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It is completely wrong... JavaScript is client side technology (your browser), PHP is server side technology (your web server). To do what you want, you SHOULD just wrap the image in a link:

<a href="where-to-go.php"><img src="" alt="description" /></a>

If you MUST use JavaScript, then you can use onclick() to redirect:

onclick="document.location( 'where-to-go.php' );"

If you want to also set the SESSION then add a parameter to the URL and catch it on the receiving page:

where-to-go.php?action=some-action-taken

Then in your PHP script (where-to-go.php):

if( isset( $_GET['action'] ) && $_GET['action'] == 'some-action-taken' )
{
    $_SESSION['s1'] = 12;
}

I hope this helps... I'll be hiding for the rest of the day :B

Cheers,
Rob.


On 11-05-20 09:05 AM, Negin Nickparsa wrote:
i want to when clicking on the image then go to other page or set my
$_SESSION

i have this in php code:
echo"<img src=' ' onclick='$_SESSION['s1']=12(i mean a number)';/>";
how can i correct this
or if it is completely wrong how 2 solve it?
i tried to set header in onclick too but i think it can't do because header
is function of php and i echoed the html tag


--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux