我希望在没有提醒并确认的情况下将表单作为消息提交后显示当前文件中所做的更改。我该怎么办?
我用以下语言更新语言:
$query="update `account_detail` set `prompt_language`= '$language' WHERE `org_id`='".$_SESSION['account_id']."'";
$result = $mysqli->query($query) or die($mysqli->error);
$Msg="updated language to $language";
function logToFile($filename, $msg)
{
$fd = fopen($filename, "a");
$str = "[" . date("Y/m/d h:i:s", mktime()) . "] " . $msg;
fwrite($fd, $str . "\n");
fclose($fd);
}
logToFile("change.log", "updated language to $language");
header("location:".SITE_URL."index.php?view=view_service");
我把所有的cheanges放在file.And也想显示为消息。
答案 0 :(得分:0)
有些事情:
<?PHP
if(isset($_REQUEST['something']))
{
echo('you made some changes...');
}
else
{ ?>
<form method="POST">
<input name="something" type="text" />
<!-- rest of code here... -->
<button type="submit">
</form>
<?PHP
}
?>
逻辑是,如果设置了变量(即已提交表单),则向页面发出消息,然后显示表单。
答案 1 :(得分:0)
尝试这样的事情:
您的观看页面:
<body>
<div id="message"><?PHP
if(isset($_REQUEST['msg']))
{
echo $_REQUEST['msg'];
}
?>
</div>
<form method="POST" action="submit.php">
<input name="language" type="text" />
<!-- rest of code here... -->
<button type="submit" >SUBMIT</button>
</form>
</body>
您的submit.php
<?php
if(isset($_POST['language'])){
$msg=array();
$language=$_POST['language'];
$Msg="updated language to $language";
logToFile("change.log", "updated language to $language");
////yor rest pf the code
header("location:view1.php?view=view_service&msg=".$Msg);
}
function logToFile($filename, $msg)
{
$fd = fopen($filename, "a");
$str = "[" . date("Y/m/d h:i:s", mktime()) . "] " . $msg;
fwrite($fd, $str . "\n");
fclose($fd);
}
?>