check a button

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
M.K_Soft
Forum Newbie
Posts: 6
Joined: Sat Dec 19, 2009 2:01 pm

check a button

Post by M.K_Soft »

hi.
i wanna check a button if it clicked or not. what should i do in PHP?
penkomitev
Forum Newbie
Posts: 6
Joined: Sat Dec 26, 2009 10:40 am
Location: Plovdiv, Bulgaria

Re: check a button

Post 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
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: check a button

Post 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.
synical21
Forum Contributor
Posts: 150
Joined: Tue Jul 28, 2009 8:44 am
Location: London UK

Re: check a button

Post 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
Post Reply