You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PHP+MySQL邮箱验证问题:点击验证链接后网站空白无反应

Troubleshooting the Blank Page in verify.php

Hey Jerome, let's figure out why your verify.php is showing a blank page after clicking the email link—silent failures like this are almost always fixable with a few quick checks. Here's what to look for first:

1. Enable Error Display (Critical First Step)

PHP often suppresses errors by default on production servers, which leaves you with a blank page instead of useful clues. Add these lines at the very top of verify.php to force all errors to show up:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

Reload the page after clicking the link again—you’ll likely see a clear error message (like an undefined variable, missing database connection, or SQL syntax mistake) that points straight to the issue.

2. Check if the Verification Token is Being Passed Correctly

Double-check that the link in your email includes a valid token parameter (e.g., verify.php?token=your-unique-token-here). Then add a quick debug line at the start of verify.php to confirm the script is receiving it:

// Debug: See what parameters are coming in
var_dump($_GET);
exit;

If the token key is missing or empty, you’ve got a problem with how the link is generated in your registration code. If it’s present, remove this debug line and move on.

3. Validate Your Database Logic

Most verification scripts involve updating a user’s status in the database. Common issues here include:

  • Missing database connection: Did you forget to include your database connection file (e.g., require_once('db-connect.php');)? If the script can’t connect to the DB, it’ll fail silently.
  • Broken SQL query: Check for typos in table/column names, or missing quotes around string values (like the token). For example, a query like UPDATE users SET verified = 1 WHERE token = $token will fail if $token is a string—use prepared statements (safer) or wrap the token in single quotes.
  • No check for query success: After running your UPDATE/SELECT query, add a check to see if it worked. For example:
    $result = mysqli_query($conn, $sql);
    if (!$result) {
        die("Query failed: " . mysqli_error($conn));
    }
    

4. Ensure You’re Outputting Content or Redirecting Properly

If the verification succeeds but you don’t see anything, it’s probably because the script isn’t outputting a success message or redirecting.

  • If you’re using header('Location: success-page.php'), make sure to add exit; immediately after it—otherwise, the script might keep running and hit an error later.
  • If you want to show a message directly, add HTML output like:
    echo "<h2>Your account has been verified successfully!</h2>";
    

5. Check for Syntax Errors

A missing semicolon, mismatched curly brace, or misspelled function can cause PHP to crash without showing an error (especially if error display is off). Use a code editor with syntax highlighting to scan for obvious typos, or run your script through a PHP linter if you have one available.

Start with enabling error display—it’s the fastest way to pinpoint the exact issue. Once you see the error message, fixing it should be straightforward!

内容的提问来源于stack exchange,提问作者Jerome

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 03:33:29