Setting a PHP variable on button click

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hibbeac1
Forum Newbie
Posts: 13
Joined: Thu Oct 30, 2003 10:25 am

Setting a PHP variable on button click

Post by hibbeac1 »

Hi,

I would like to find out if there is a way to set a PHP variable when a submit button is clicked. I need a variable set to true so that after the button is clicked the page is reopened and the header/footer of web page will not be displayed. This is how i've tried to do it:

the buttons code:
<input class ="noprint" type="image" src="images/print.png" name="Print" onClick="<?php $hide = "hello"; ?>; document.form.action='home.php';">

The handle header code:
if (!isset ($hide))
include_once ('./csadminheader.html');
}

So if the button has been clicked hide will be true and the header will not be included if button hasn't been clicked then the header will still be shown.

However i cannot get this to work and have tried different combinations. Any input would be appreciated. Thanks.
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

no, that's Client-Side.
try Javascript, you can do that with it.
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

this is a script that SUBMITS information to a script that processes the information, right?
why not just add a <input type="hidden" name="hide" id="hide" value="1" /> to the form?
then when it's called again it will work.
just check for it with

Code: Select all

/* some stuf */
if($hide){
   /* what to do if set */
}else{
   /* what to do if not set */
}
/* more stuff */
hibbeac1
Forum Newbie
Posts: 13
Joined: Thu Oct 30, 2003 10:25 am

Post by hibbeac1 »

Thankyou this has worked
Post Reply