在数据输入表单中,我希望当单击“提交”按钮时,它不会离开表单所在的页面。
提交论坛后,会向用户显示一个弹出窗口,其中包含表单已发送的信息!
在搜索中,我知道AJAX存在,但我不知道如何完全实现它。我是 PHP 新手,我希望有人能帮助我!
对不起我的英语!
HTML:
<form action="php/newsletter.php" method="post" class="formulario">
<input type="text" name="email" placeholder="Email" required>
</div>
<div class="ss-item-required" style="text-align:center;">
<button type="submit" class="site-btn">Send</button>
</div>
</form>
PHP:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "DB";
$conexao = new mysqli($servername, $username, $password, $dbname);
if ($conexao->connect_error) {
die("Erro na conexão: " . $conexao->connect_error);
}
if (!$conexao) {
die("Erro de ligação: " . mysqli_connect_error());
}
$sql = "INSERT INTO newsletter (email) VALUES ('email')";
if (mysqli_query($conexao, $sql)) {
echo '<div id="form-submit-alert">Submitted!</div>';
} else {
echo "Erro: " . $sql . "<br>" . mysqli_error($conexao);
}
?>
皈依舞
汪汪一只猫
翻过高山走不出你
烙印99
相关分类