Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我只想在从表单发布的输入顶部添加一些额外的文本,如下例所示:
$username = $_POST['username']; $sql = mysql_query("INSERT INTO customers (Username) VALUES('$username')");
但我希望表中的值是:'username*text' 也就是说,如果用户将用户名输入为 'john',我希望将其作为 'john*text' 输入表中。
提前谢谢。
尝试:
$username = mysql_real_escape_string($_POST['username']) ."*text";
转义用户的输入以避免sql注入
利用:
$username = $_POST['username'].'*text';//hence you get *text postfix to every value $sql = mysql_query("INSERT INTO customers (Username) VALUES('$username')");
现在检查你的结果,它肯定会工作。