1 回答

TA贡献1793条经验 获得超6个赞
一旦您成功查询并将输入成功添加到数据库,您将需要创建一个 header() 重定向到您的原始页面。
像这样的东西:
if (isset($_POST['sendrequest'])) {
$date = date ('F d, Y');
$enduser = $_POST['userrequester'];
$priority = $_POST["priority"];
$itemtype = $_POST["typeitem"];
$summary = $_POST["summary"];
$status = "new";
// Pretty sure this can be wrapped in your if statement, may need to test that.
// --> $request->createticket($enduser, $priority, $itemtype, $status, $summary, $date);
if($request->createticket($enduser, $priority, $itemtype, $status, $summary, $date)){
$postMSG = "success"; // sending the success message over url as $_GET
$host = $_SERVER['HTTP_HOST']; // SERVER
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); // Directory
$extra = 'ticketformpage.php'; // the page your form is on
header("Location: http://$host$uri/$extra?$postMSG"); // header redirect with url post added
}
现在在您希望显示成功消息的页面上,我们检查 GET 全局是否设置为成功$_GET['success'],如果成功则我们设置变量并显示它们并添加一些 css。
<?php
$msg = NULL; // we set to NULL for when the message is not needed
if(isset($_GET['success'])){
$msg = "Thank you for submitting through our ticket system.";
}else{
$msg = NULL;
}
注意:我在<span>标签中添加了成功并添加了padding和border radius,limegreen bg和darkgreen颜色以与成功相关联。10px margin-top for form。
<div id="req_form" class="inputs">
<span class="success"><?=$msg?></span> <!--// add the success variable here-->
<div id="error"></div>
<form id="form" action="inputtest.php" method="POST">
CSS:
form {
margin-top: 10px;
}
.success {
background-color: limegreen;
color: darkgreen;
padding: 10px;
border-radius: 5px;
}
- 1 回答
- 0 关注
- 120 浏览
添加回答
举报