I have a form which sumbit a message. Now I would like to show an alert to user that the submitting is done. by regular alert in js it is possible but with costume alert I could not stop redirecting to another page. here is the codes
<form action="suggest_data.php" method="post" onsubmit="return check_suggest()">
<div id="login_form">
<div id="user_reg">
<span>email</span>
<input type="text" name="email">
</div><!--user_reg-->
<div id="user_reg">
<div id="user_reg">
<span>suggestion</span>
<textarea name="suggest"></textarea>
</div><!--user_reg-->
<div id="user_reg">
<input type="submit" value="submit">
</div><!--user_reg-->
</div><!--suggestform-->
</form>
and the js codes is here:
function check_suggest(){
var error=0;
var email=$("input[name='email']").val();
var regex=(/.+\@.+\..+/);
if(regex.test(email)==false){
error=1;
$("input[name='email']").addClass('error');}
else{
$("input[name='email']").removeClass('error');}
if(error==1){
return false;
}
else {
swal("Good job!", "You clicked the button!", "success")
};
}
and php code is here:
<?php
session_start();
include ('injection.php');
include_once ('func_database.php');
$object=new func_class;
$email=$_POST['email'];
$email=check($email);
$email=addslashes($email);
$suggest=$_POST['suggest'];
$suggest=check($suggest);
$sql="insert into tsuggest (email, suggest) values('$email', '$suggest')";
$st=$object->update($sql);
header('location:suggest.php');
?>
the problem is when user submit the form, alert is coming just before redirecting and then disappear. I just want to have a costume alert like js alert which stop until press ok.