在 jQuery 中提交表单后,在 PHP 中完成
我有一个 php 文件,它包含一个文本文件和提交按钮以及一个 div,下面是代码
Page1.php
<form name="form1" method="post">
<input type="text" name="email1">
<input type="submit" name="submit" value="send" class="submit_class">
<div class="suc_box">You have Entered</div>
</form>
if($_POST['submit']) {
$v1 = $_POST['email1'];
// $query1 = here some code to insert into database
if($query1 > 0){
//here i want to display the div `suc_box`.. Here how i can show that div
}
}
和 jQuery 代码:
$(document).ready(function(){
$('suc_box').hide();
$('suc_box').click(function(){
$(this).hide();
});
});
问题:当表单提交后,如何显示/显示 suc_box
它插入数据库了吗?
I have a php file and it contains a textfiled and submit button and a div and below is code
Page1.php
<form name="form1" method="post">
<input type="text" name="email1">
<input type="submit" name="submit" value="send" class="submit_class">
<div class="suc_box">You have Entered</div>
</form>
if($_POST['submit']) {
$v1 = $_POST['email1'];
// $query1 = here some code to insert into database
if($query1 > 0){
//here i want to display the div `suc_box`.. Here how i can show that div
}
}
And the jQuery code:
$(document).ready(function(){
$('suc_box').hide();
$('suc_box').click(function(){
$(this).hide();
});
});
Question: How can I show/display that suc_box
when form is submitted after it inserted into database?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 AJAX 轻松完成。您有一个带有表单的 php 文件,另一个用于处理数据:
//form_file.php
//process.php
它未经测试,但您已经明白了。
验证电子邮件字段
You can do it easily with AJAX. You have one php-file with the form and another one for processing the data:
//form_file.php
//process.php
It's untested, but you get the idea.
validating email field
如果我猜对了,你可以这样做,但我建议你研究一下 ajax 来做你想做的事
If ive got you right you could do this however I would suggest looking into ajax to do what you want