🎉 سال نو، مهارت نو، مشاوره رایگان نقشه راه برنامه نویسی (آفر ویژه ثبت نام قبل از افزایش قیمت 🔥)
۰ ثانیه
۰ دقیقه
۰ ساعت
۵ حسینی
عدم بالا اومدن صفحه verify
حسینی حل شده توسط حسینی

سلام کد‌ها تا مرحله پایین کار می‌کنن بعد از ان صفحه verify را بالا نمیاد و صفحه login میاد نمی‌دونم مشکل کجاست

<?php
include "bootstrap/init.php";
if($_SERVER['REQUEST_METHOD'] == 'POST' ){
    $action = $_GET['action'];
    $params = $_POST;
    if($action == 'register'){
        if(empty($params['name']) || empty($params['email']) || empty($params['phone'])){
            serErrorAndRedirect('all input field is required','auth.php?action=register');
        }
        if(!filter_var($params['email'] ,FILTER_VALIDATE_EMAIL)){
            serErrorAndRedirect('enter the valid email','auth.php?action=register');
        }
        if(isUserExists($params['email'] ,$params['phone'])){
            serErrorAndRedirect('user exists whih this data','auth.php?action=register');
        }
        if(CreatUser($params)){
            $_SESSION['email'] = $params['email'];
            redirect('auth.php?action=verify');
        };
    }
}
if(isset($_GET['action']) && $_GET['action'] == 'verify' && !empty($_SESSION['email']))
        include 'tpl/verify-tpl.php';
if(isset($_GET['action']) && $_GET['action'] == 'register'){
    include 'tpl/register-tpl.php';
}else{
    include 'tpl/login-tpl.php';
}  
<?php
function isUserExists(string $email = null, string $phone = null): bool
{
    global $pdo;
    $sql = 'SELECT * FROM users WHERE email = :email OR phone = :phone';
    $stmt = $pdo->prepare($sql);
    $stmt->execute(['email' => $email ?? '', 'phone' => $phone ?? '']);
    $record = $stmt->fetch(PDO::FETCH_OBJ);
    return $record ? true : false;
}
function CreatUser(array $userData):bool{
    global $pdo ;
    $sql = "INSERT INTO users (name,email,phone) VALUES (?,?,?)";
    $stmt= $pdo->prepare($sql); 
    $stmt->execute([$userData['name'] ,$userData['email'],$userData['phone']]);
    return $stmt->rowCount();
   }
   function createLoginToken():array{
    global $pdo;
    $hash = bin2hex(random_bytes(8));
    $token = rand(100000,999999);
    $expird_at = time() + 600 ;
    $sql="INSERT INTO tokens (token,hash,expired_at) VALUES (:token,:hash,:expired_at);";
    $stmt=$pdo->prepare($sql);
    $stmt->execute([':token' => $token,':hash' => $hash,':expired_at' => date("Y-m-d H:i:s",$expird_at)]);
    return [
        'token' => $token,
        'hash' => $hash
    ];
   }
حسینی ۲۳ بهمن ۱۴۰۲، ۱۸:۳۷
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Verify Page</title>
    <link rel="stylesheet" type="text/css" href="<?= assets('css/styles.css') ?>">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet" />
    <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
    <link href="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/4.2.0/mdb.min.css" rel="stylesheet" />
</head>
<body>
    <!-- Section: Design Block -->
    <section class="background-radial-gradient overflow-hidden">
        <div class="container px-4 py-5 px-md-5 text-center text-lg-start my-5">
            <div class="row gx-lg-5 align-items-center mb-5 justify-content-center">
                <div class="col-lg-6 mb-5 mb-lg-0" style="z-index: 10">
                    <h1 class="my-5 display-5 fw-bold ls-tight" style="color: hsl(218, 81%, 95%)">
                        7Learn Auth <br />
                        <span style="color: hsl(218, 81%, 75%)">Verify Page</span>
                    </h1>
                    <?php if(!empty($_SESSION['error'])) :?>
                        <h3 class="text-danger">Fix this error and try again:</h3>
                        <h4 class="text-danger mb-4 opacity-70">
                            <?= $_SESSION['error'] ?>
                        </h4>
                        <?php
                          unset($_SESSION['error']);
                        endif; ?>
                </div>
                <div class="col-lg-6 mb-5 mb-lg-0 position-relative">
                    <div id="radius-shape-1" class="position-absolute rounded-circle shadow-5-strong"></div>
                    <div id="radius-shape-2" class="position-absolute shadow-5-strong"></div>
                    <div class="card bg-glass">
                        <div class="card-body px-4 py-5 px-md-5">
                            <form action="<?= site_url('auth.php?action=verify') ?>" method="post">
                                <!-- Token input -->
                                <div class="form-outline mb-4">
                                    <input type="text" name="token" id="token" class="form-control" />
                                    <label class="form-label" for="token">Enter Token</label>
                                </div>
                                <!-- Submit button -->
                                <button type="submit" class="btn btn-primary btn-block mb-4">
                                    Submit
                                </button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/4.2.0/mdb.min.js"></script>
</body>
</html>
حسینی ۲۳ بهمن ۱۴۰۲، ۱۸:۳۸
حسینی ۲۳ بهمن ۱۴۰۲، ۱۸:۳۸

توی صفحه سایت بخش url این هست http://7learn.php/7auth/auth.php?action=verify# 

بعد از verify # میاد نمی‌دونم چرا ولی فکر می‌کنم مشکل همین باشه 

بهترین پاسخ
حسینی ۲۳ بهمن ۱۴۰۲، ۱۸:۴۰

در کل میخام اینو بگم تا اینجایی کار همچی اوکی است ولی بعد از این هر چی کد میزنم صفحه verify نمیاد بجاش login میاد

حسینی ۲۳ بهمن ۱۴۰۲، ۱۸:۴۳