希望在注册后将用户引导至其帐户 [英] Want to direct user to their account after sign up

查看:123
本文介绍了希望在注册后将用户引导至其帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是创建一个简单的注册表单,并希望我的用户在注册后直接进入其帐户页面。但即时通讯有问题,因为信息将被存储在数据库中,但页面不会被引导。

just creating a simple signup form, and want my users after they've signed up to be direct to their account page. however im having problems as the information will get stored in the database but the page will not get directed.

<?php
session_start();
include "php/config/database.php";

if (isset($_POST['submit'])) {
    $FirstName = $_POST['FirstName'];
    $Surname   = $_POST['Surname'];
    $Email     = $_POST['Email'];
    $Password  = $_POST['Password'];

    // Check if data exists already in the database

    $exists  = mysqli_query($conn, "SELECT Email FROM Users WHERE Email = '$Email'");
    $row     = mysqli_fetch_array($exists);
    $dbEmail = $row['Email'];
    if ($Email == $dbEmail) {
        die("Email already taken.");
    }
}

$registerUser = "INSERT INTO Users(FirstName,Surname,Email,Password)VALUES('$FirstName','$Surname','$Email','$Password')"; { // Select ID from registered user
    $selectID           = "SELECT UserID FROM Users WHERE Email = '$Email'";
    $selectID_Query     = mysqli_query($conn, $selectID);
    $fetch              = mysqli_fetch_array($selectID_Query);
    $userID = mysqli_insert_id($conn);
    $userID             = $fetch['UserID'];
    $_SESSION['UserID'] = $UserID;
    if (mysqli_query($conn, $registerUser)) {
        header("Location: account.php");
    } else {
        echo "<script>alert('error while registering you...');</script>";
    }
}
?>
<html>
<head> 
  <meta charset="UTF-8">
    <title>background</title>
 </head>
  <body>

</body>
</html>


推荐答案

试试:

if (mysqli_query($conn, $registerUser)) {
    <script>window.location = "http://www.yoururl.com/path/to/account.php";</script>
  } else {
    echo "<script>alert('error while registering you...');</script>";
}

这篇关于希望在注册后将用户引导至其帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆