[英]Showing bootstraps modal after redicted to page
So I have been making a website where settings.php and saveSettings.php page where it insert $_POST
functions to database. 因此,我一直在创建一个网站,在该网站上settings.php和saveSettings.php页面将
$_POST
函数插入数据库。
Here is part of settings.php 这是settings.php的一部分
echo '
<form action="saveSettings.php" method="POST">
<div class="form-group">
<textarea class="form-control no-resize" rows="4" id="profilecomment" name="profilecomment"></textarea>
</div>
<input type="submit" class="btn btn-success" name="submit" style="margin-top:10px" value="Submit" />
</form>
';
and here part of saveSettings.php 这是saveSettings.php的一部分
$userComment = $_POST["profilecomment"];
$updateComment = "UPDATE users SET comment = '$userComment' WHERE steamid = '$steamID' ";
header('Location: settings.php');
This is what I have tried: 这是我尝试过的:
I added my modal load script to settings.php page 我将模态加载脚本添加到settings.php页面
<script>
$(window).load(function(){
$('#settingsSave').modal('show');
});
</script>
And modal script: 和模式脚本:
<div class="modal fade" id="settingsSave" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<p>You have successfully saved your settings!</p>
</div>
</div>
</div>
</div>
I am not sure if it does not popup because of that: 我不确定是否因为这个原因没有弹出窗口:
header('Location: settings.php');
I hope I can get some help. 希望我能有所帮助。
First, please be aware of mysql Injection , I see you dont escape your POST parameters. 首先,请注意mysql Injection ,我看到您没有逃避POST参数。
Do it like this: 像这样做:
$userComment = mysql_real_escape_string($_POST["profilecomment"]);
or use mysqli instead of mysql 或使用mysqli代替mysql
To your question: 对你的问题:
$(window).load(function(){
$('#settingsSave').modal('show');
});
is wrong, you must use something like: 是错误的,您必须使用类似以下的内容:
$( document ).ready(function() { <? if(isset($_GET['save'])){ echo "$('#settingsSave').modal('show');"; } ?> });
ans pass a parameter to your new location ans将参数传递到您的新位置
header('Location: settings.php?save');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.