我有這種完美工作的表單。但是,我想在提交表單時隱藏表單。基本上,我想隱藏整個div,從<div class="HideSuccess">
開始,當它成功提交或表單提交時有/無錯誤。成功提交時隱藏DIV
我該如何解決這個問題?
<?php
if (isset($_POST['submit'])) {
$Fname = $_POST['fname'];
$Email = $_POST['email'];
$fp = fopen("data.txt","a");
if (!$fp) {
echo 'Error!';
exit;
}
if (@fwrite($fp, $Fname.'|'.$Email."\n")) {
echo '<p class="thanks">Success<p>';
} else {
echo '<p>Error!</p>';
}
fclose($fp);
}
?>
<div class="HideSuccess">
<form name="input" method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>">
<input type="text" name="fname" id="fname" placeholder="Full Name" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Full Name'" required />
<input type="email" name="email" id="email" placeholder="Your Email" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Your Email'" required />
<input class="button" type="submit" name="submit" value="Submit" /></p>
</form>
</div>
我不確定如何在代碼中嵌入php代碼,你能否完成它?問題給出的代碼是完整的代碼,並且它在同一頁面上。 –
@ElaineByene,你去了嗎? –
謝謝你這麼多:) –