temporary disable button using php

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
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

temporary disable button using php

Post by Goofan »

Ok, so i have researched some about disable a button and everyone says that u need to use js. now i dont know that much js so i wonderd if there is a way to do this in php only.
If not then please post a sample code that would temporary disable a button for "exampel 3 seconds".
This is ment to do:
example:
$rand = rand(0,10)
$brand = rand(0,10)
if ($brand == $rand)
{
$input = rand(7500,65000)
$sql="UPDATE konto SET pengar=$pengar + $input WHERE saved_id=$id";
$result = mysql_query($sql) or die(mysql_error());//Skicka info till tabell

header('Refresh: 3; url=refresh/two=two(main).php?saved_id='.$id);//Skickas till angiven sida. //and at the same time the button would be disabled


}
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: temporary disable button using php

Post by requinix »

Not all browsers respect the Refresh header. Find another way.

Spoiler: you won't find one. JavaScript is required for some part of it.
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: temporary disable button using php

Post by daedalus__ »

dont be intimidated by js its easy.

http://www.google.com/search?q=disable+ ... javascript

http://www.google.com/search?q=create+a ... +javscript

im not sure what you are trying to describe with your example though.

they click the button, it updates the database then redirects them?
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: temporary disable button using php

Post by Goofan »

they click a button it randomize a number if they win they will be shown a message YOU WON!...
the problem is that when you win it redirect in a header "takes 3 seconds" but if u accidentaly click again this will not happend...


-Hope you understand
-Thomas
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: temporary disable button using php

Post by daedalus__ »

okay i get it now. well follow those links and use javascript to do this. it's real easy i promise.
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: temporary disable button using php

Post by Goofan »

I will and thanks daed :D (again)
Post Reply