簡體   English   中英

插入數據后的消息

[英]Message after a data is inserted

我的action.php頁面是如何在提交表單並在mysql中插入記錄后使消息顯示在頁面頂部的。

<?php $email =$_POST["email"];
include "includes/db_config.php";

$sql = "INSERT INTO subscribers(email)
VALUES('$email')";

if (mysqli_query($conn, $sql)) {
  header('location:index.php?subscribe=yes');

} else {
    echo "Failed" .  $sql . "<br>" . mysqli_error($conn);
}


?>

然后在index.php

<?php
    if ($_GET['subscribe'] =='yes'){
    echo 'You succesully subscribe to our exclusive promos';
    }
    ?>

為此,可以使用頁面index.php JavaScript警報框。

<?php
    if ($_GET['subscribe'] =='yes'){
       echo '<script language="javascript">';
       echo 'alert("Form has been submitted")';
       echo '</script>';
    }
?>

希望能幫助到你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM