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

PHP+MySQL注册表单提交后始终提示signup=empty问题求助

Troubleshooting Your Empty Signup Form Fields

Hey Chris, let's break down why all your form fields are registering as empty even when you fill them out. Your debug output showing all bool(true) for the empty checks tells us the server isn't receiving any data from those fields, or something is wiping them before the validation check. Here are the most likely fixes to try:

1. Verify Your Form Data is Actually Being Sent

First, let's confirm if the POST data is reaching your signup.inc.php file. Add this code at the very top of signup.inc.php (before any other code):

var_dump($_POST);
exit;

Submit your filled-out form and check the output:

  • If the result is an empty array (array(0) { }), that means your form isn't sending data to the correct file. Double-check the action attribute in your signup form:
    Your form uses action="includes/signup.inc.php" — make sure your file structure matches this:
    root/
    ├── signup.php
    ├── includes/
    │   ├── signup.inc.php
    │   └── dbh.inc.php
    ├── header.php
    └── footer.php
    
    If signup.php is in a subfolder (like public/signup.php), adjust the action path to ../includes/signup.inc.php.
  • If the $_POST array has your form values (like ["first"]=> string(5) "Chris"), then the issue happens after you retrieve the data — move to the next step.

2. Check Your Database Connection

You're using mysqli_real_escape_string($conn, $_POST['first']) to sanitize inputs, but if your database connection in dbh.inc.php fails, $conn will be false, and mysqli_real_escape_string will return an empty string. That would make all your $first, $last, etc. variables empty, triggering the "signup=empty" redirect.

To test this, add this line right after include_once 'dbh.inc.php'; in signup.inc.php:

var_dump($conn);
exit;

If the output is bool(false), fix your database connection settings in dbh.inc.php (check host, username, password, and database name for typos).

3. Rule Out Sanitization Issues

If your database connection is valid, try temporarily removing the mysqli_real_escape_string calls to see if variables get populated:

// Replace sanitized lines with direct POST retrieval:
$first = $_POST['first'];
$last = $_POST['last'];
$email = $_POST['email'];
$uid = $_POST['uid'];
$pwd = $_POST['pwd'];

Then re-run your original debug code. If the empty checks now return bool(false) for filled fields, the problem might be with the escape function (unlikely if your connection is good, but worth testing).

4. Confirm Form Field Names Match

Double-check that the name attributes in your form exactly match what you're retrieving in signup.inc.php:

  • Your form has <input type="text" name="first"> and you use $_POST['first'] — that's correct.
  • A tiny typo (like frist instead of first) would cause the field to be missing from $_POST, so scan each field's name carefully.

Try these steps one by one, and you should find the root cause quickly!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.28 07:07:00