/    Sign up×
Community /Pin to ProfileBookmark

Disable A Button After Click

how can convert the button to disable after click to ensure the data send once

if($_POST[“ok”]){
if($_
POST[“username”]!=”” ) {

$username=$_POST[“username”] ;

mysql_query(“insert into switch VALUES (”,’$username’)”);

$msg=”was inserted “;
}

else {
$msg=” not inserted”;

}

}
<form id=”form1″ name=”form1″ method=”post” action=”” >
<table width=”80%” border=”0″>
<tr>
<td colspan=”3″><div align=”center”><?php echo $msg ?></div></td>
</tr>
<tr>
<td width=”32%”><input type=”text” name=”username” id=”username” /></td>
<td width=”63%”>&#1575;&#1604;&#1575;&#1587;&#1605; </td>
<td width=”5%”>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type=”submit” name=”ok” id=”ok” value=”&#1581;&#1601;&#1592;” /></td>
<td>&nbsp;</td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</form>

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogDec 16.2015 — That would be a JavaScript question, not PHP (since PHP runs on the server side, not in the browser).
Copy linkTweet thisAlerts:
@ginerjmDec 16.2015 — Very hard to see the total picture here since your snippet of code is not going to run anyway.

As I see it though, once you hit the submit button and your script executes, you SHOULD be sending something back to the client. Therefore you are in total control of what the user sees and has access to after that click.

PS - how do you know that your query ran successfully and did your insert? You don't check the result of the query call.

PPS - you really should validate the input before putting it into a query. Basic security precaution #1.

PPS again - you also really should stop using the MySQL* extension since it is deprecated and is no longer available in the latest version of PHP. Try one of the other ones.
Copy linkTweet thisAlerts:
@Sh_e2000authorDec 17.2015 — Thank you my friends
×

Success!

Help @Sh_e2000 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...