marmite Posted April 23, 2007 Share Posted April 23, 2007 Is there any way to change a $_POST variable when someone clicks on a link? (Situation is: I have three buttons, saying, e.g. "view all blank cards". When the user clicks a button, I want to take them to greetingscards.php, with the $_POST variable ['message' set to Blank - the POST variable is used in the SQL used to retrieve the cards.) <a href="/greetingscards.php" onclick=<? $_POST['message']='blank' ?>><img src="images/bulk_blank_a.gif" alt="Cards Un Limited" width="163" height="26" border="0" /></a> I'm not getting anywhere and beginning to wonder whether this is possible.. any ideas gratefully received! Link to comment https://forums.phpfreaks.com/topic/48285-php/ Share on other sites More sharing options...
trq Posted April 23, 2007 Share Posted April 23, 2007 The onlick event is client side (Javascript) and will not trigger php (server side). Link to comment https://forums.phpfreaks.com/topic/48285-php/#findComment-236037 Share on other sites More sharing options...
saint959 Posted April 23, 2007 Share Posted April 23, 2007 hi try this <a href=\"/greetingscards.php?message=""\" ?> ><img src="images/bulk_blank_a.gif" alt="Cards Un Limited" width="163" height="26" border="0" /></a> Link to comment https://forums.phpfreaks.com/topic/48285-php/#findComment-236041 Share on other sites More sharing options...
Dragen Posted April 23, 2007 Share Posted April 23, 2007 What saint959 has posted would change the message as get, not post. As thorpe said onclick is javascript so you can't use it to change php.. trust me I've tried.. Your best bet is probably to use a form. Link to comment https://forums.phpfreaks.com/topic/48285-php/#findComment-236045 Share on other sites More sharing options...
marmite Posted April 23, 2007 Author Share Posted April 23, 2007 The onlick event is client side (Javascript) and will not trigger php (server side). Thanks So, is the only way to achieve this through three forms (one for each button)? Link to comment https://forums.phpfreaks.com/topic/48285-php/#findComment-236046 Share on other sites More sharing options...
Dragen Posted April 23, 2007 Share Posted April 23, 2007 um.. I think you could do it with just one, because if only one input or whatever you use is entered, then the others will return blank, and not effct it. Althought you might find that they will collide with each other.. give it a try EDIT: Or if it's not too important, you could use $_GET method. it would mean that users could input there own values, buit sometimes that doesn't matter. I use get a lot on my site for things as users can then bookmark pages with the settings as they wish etc Link to comment https://forums.phpfreaks.com/topic/48285-php/#findComment-236050 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.