Page 1 of 1

check a button

Posted: Sat Dec 26, 2009 10:51 am
by M.K_Soft
hi.
i wanna check a button if it clicked or not. what should i do in PHP?

Re: check a button

Posted: Sat Dec 26, 2009 11:52 am
by penkomitev
You have to clarify what you exactly mean.

Checking whether a button has been clicked does not make sense unless you declare what you exactly need.

P.S. Please, for future posts, have in mind a sentence begins with capital letter. This makes the text much more pleasant for all people reading.

Penko

Re: check a button

Posted: Sat Dec 26, 2009 11:57 am
by Apollo
M.K_Soft wrote:i wanna check a button if it clicked or not. what should i do in PHP?
In addition to penkomitev's comment, remember: PHP only works server-side, to generate the HTML that is sent to the user.

Clicking a button is something that usually happens client-side, i.e. after the user received your PHP's result.

Re: check a button

Posted: Sat Dec 26, 2009 12:18 pm
by synical21
Give the page an id (http://www.mysite.com/page.php?id=2344, then create a database with a table which can contain the page id's then create a column called click.

When the button is clicked run a script what updates the database WHERE page_id = "current page id" and SET click = 1.

Now on the original page you can use a conditional statement such as if to make the page change depending on if the button has been click E.G

Code: Select all

if (click == 1)
{
 
echo "button has been clicked";
}
 
else{
 
Run page as normal