如何停止頁面加載或刷新時提交表單?我現在不擔心參數化。提前致謝!從頁面加載時停止表單
$firstname = $_POST['firstname']
$lastname = $_POST['lastname']
$sql = ("INSERT INTO table (firstname, lastname) VALUES ('$_POST[firstname]' , ' $_POST[lastname]')");
mysql_query($sql) or die ("Error is: ".mysql_error());
<form name="add-name" id="add-name" method="post" action="/add-name.php">
<button type="submit">Save</button>
<fieldset>
<label>First Name *</label>
<input name="firstname" type="text" id="firstname" />
</fieldset>
<fieldset>
<label>Last Name *</label>
<input name="lastname" type="text" id="lastname" />
</fieldset>
</form>
參見[防止被提交兩次](http://stackoverflow.com/questions/3614197/prevent-form-from-being-submitted-twice )。 –