jug Posted December 6, 2006 Share Posted December 6, 2006 Hi.I need to click an image and it to run some php script that sets a php variable and reloads the same page.I know it sounds simple but i've tried every different way I can think of and i'm guessing it's just something basic i've missed.I've tried onclick of the image, a href and a onclick, making the image the 'submit button' of a form etc..Any response would be appreciated.Thanks in advance.Regards,Jug Quote Link to comment Share on other sites More sharing options...
taith Posted December 6, 2006 Share Posted December 6, 2006 heres the easiest way of setting a link to the same page, with putting any/if $_GET[] vars[code]<a href="?op=test1"><img src=""></a>[/code]that'll link you to the same page, but have the ?op active... much easier and faster then making it a form. Quote Link to comment Share on other sites More sharing options...
jug Posted December 6, 2006 Author Share Posted December 6, 2006 I haven't really been using variables in the URL for my site, so is there any other way? Quote Link to comment Share on other sites More sharing options...
taith Posted December 6, 2006 Share Posted December 6, 2006 no... not efficiently... and theres no time like now to start ;-) it makes page dynamics SOOO much easier and faster... Quote Link to comment Share on other sites More sharing options...
papaface Posted December 6, 2006 Share Posted December 6, 2006 [code]<?phpif (isset($_POST["hidden"])) {$variable = "hello";echo $variable; }else echo '<form action="' .$_SERVER["PHP_SELF"]. '" method="post" enctype="multipart/form-data"><INPUT TYPE="image" SRC="imageurl" BORDER="0" ALT="Submit Form"><input name="hidden" type="hidden" value=""></form>';?>[/code]That would do what you want, i think. Quote Link to comment Share on other sites More sharing options...
jug Posted December 7, 2006 Author Share Posted December 7, 2006 Spot on - works perfectlyThanks!Jug Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.