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

PHP编辑表单全名仅显示首单词,需实现完整字符串显示

Fix: Full Name Only Shows First Word in Input Field

Got it, let's fix this issue right away! The root cause here is that your value attribute for the fullname input isn't wrapped in quotes. When the full name contains spaces (like "Ronak Solanki"), the HTML parser treats everything after the space as a separate attribute, so only the first word gets displayed in the input.

Here's the exact fix:

Locate this line in your code:

<input type="text" class="form-control" name="fullname" placeholder="Fullname" value=<?php echo $row["sfullname"]; ?>>

Replace it with this corrected version:

<input type="text" class="form-control" name="fullname" placeholder="Fullname" value="<?php echo htmlspecialchars($row["sfullname"], ENT_QUOTES); ?>">

Why this works:

  • Wrapping the value attribute in double quotes tells the browser to treat the entire full name string as a single value, even when it has spaces or special characters.
  • Adding htmlspecialchars() with ENT_QUOTES is a critical security practice—it escapes special characters (like quotes or angle brackets) to prevent cross-site scripting (XSS) attacks, which is essential when outputting user-supplied database data directly into HTML.

Bonus Recommendation:

You should also populate the other input fields (email, mobile, dob, address, etc.) with their corresponding values from the signup table using the same pattern. This way, the edit form will show all existing user data correctly. For example:

<input type="text" class="form-control email" name="email" placeholder="Email address" value="<?php echo htmlspecialchars($row["email"], ENT_QUOTES); ?>">

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.28 04:21:22