如果表单成功提交,我想隐藏div并显示另一个div,我想我必须使用jquery的.hide()
和.show()
类,但我不知道如何。有人可以帮助我吗?
CSS
.hidden{display:none}
.main{}
PHP
<div class="main>
<form action="" method="post">
<!--all the stuff to be hidden goes here-->
<input type="submit" name="submit">
</form>
</div>
<div class="hidden">
<div>Form has been successfully submitted</div><!-- will be visible upon successful form submision-->
</div
<?php
if(isset($_post['submit']){
if(!empty($var_1) || !empty($var_2))
{
//insert in to database
//success
}
else{
//something is wrong.
}
}
答案 0 :(得分:0)
<?php
if ( isset($_post['submit']) && (!empty($var_1) || !empty($var_2) ) {
//insert in to database
} else {
?>
<form ...>
</form>
<?
}
答案 1 :(得分:0)
我会这样解决它:
<?php
if(isset($_post['submit']){ // Form is submitted
if(!empty($var_1) || !empty($var_2))
{ // success, insert in to database
?>
<div class="hidden">
<div>Form has been successfully submitted</div>
<!-- will be visible upon successful form submision-->
</div
<?php
} // success, insert in to database
else { // something is wrong.
?>
<form action="" method="post">
<!--all the stuff to be hidden goes here-->
<input type="submit" name="submit">
</form>
<?php
} // something is wrong.
} // Form is submitted
?>