Page 1 of 1

Setting a PHP variable on button click

Posted: Wed Jan 28, 2004 7:03 am
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.

Posted: Wed Jan 28, 2004 7:28 am
by vigge89
no, that's Client-Side.
try Javascript, you can do that with it.

Posted: Wed Jan 28, 2004 7:30 am
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 */

Posted: Thu Jan 29, 2004 5:15 am
by hibbeac1
Thankyou this has worked