如何在php中提交表单后获取用户名?

时间:2017-01-04 10:18:36

标签: javascript php

if (isset($_POST['submit'])) {
    $name=$_POST['name'];
    $email=$_POST['email'];
    $enquiry=$_POST['enquiry'];
    $message=$_POST['message'];
    $insert = "insert into contact(name, email, nature, message)
    values('$name', '$email', '$enquiry', '$message')";
    if(mysqli_query($conn, $insert)) {
        header('location: contactus.php');
    }
}

我想在联系我们页面上显示弹出框,其中name($name)用户已通过联系表单提交了他/她的详细信息......!

2 个答案:

答案 0 :(得分:0)

尝试header('location: contactus.php?success&name=$name'); 并在contactus.php上

if(isset($_GET['success']))
  {
     $name=$_GET['name'];
 echo"<script>window.alert("'.$name.'");</script>";
 }

答案 1 :(得分:0)

成功插入后尝试echo "<script>alert(".$name.")</script>"