2015-10-16 26 views
-1

我想在沒有提示和確認的情況下提交表單作爲消息後,顯示當前文件中所做的更改。如何才能做到這一點?如何在不使用提示或確認的情況下在php中顯示消息?

我更新的語言:

$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"); 

我把file.And的所有cheanges也想顯示爲消息。

<?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 
    } 
?> 

的邏輯存在,如果變量被設置(即形式已提交)然後回聲出的消息的頁面,othewise顯示形式:

+0

只是附和它的頁面? –

+1

'alert'和'confirm'不是PHP的函數,除非你自己創建它們。如上所述,你可以使用'echo'。 – Script47

+0

什麼樣的信息?你的問題很不清楚。 –

回答

0

沿東西線。

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); 
} 

?> 
相關問題