[英]SESSION data cutting off at space
(signup_process.php)
$city=cleanup($_POST['city']);
echo $city;
产出:纽约
$_SESSION['city']=$city;
echo $_SESSION['city'];
产出:纽约
问题:
(signup.php)
<form method=post action='signup_process.php'>
City<input type=text name=city value=<?php echo $_SESSION['city'];?>>
输出:新
City<input type=text name=city value=<?php echo urlencode($_SESSION['city']);?>>
输出:New + York
City<input type=text name=city value=<?php echo urlencode(str_replace('+', '', $_SESSION['city']));?>>
输出:New + York
我试图将数据回显到表单中。
您必须将值放在引号中,否则浏览器会将空格后的部分解释为<input>
标记的另一个属性。 例如:
<input type="text" name="city" value="<?php echo $_SESSION['city'];?>">
在您的示例中,
<input type=text name=city value=New York>
约克是价值之后的下一个属性。
我已经解决了问题,解决方法是对HTML = space使用()
这个解决方案:
str_replace(" ", " ", $_SESSION['city'])
该方法可以在
echo '<input style="font-size: 17px;color: black;" type="text" name="us" class="form-control" disabled="disabled" value='. str_replace(" "," ",$_SESSION['username']).' >';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.