【发布时间】:2013-12-20 19:29:23
【问题描述】:
所以我有这个问题,如果我这样做。
<input type="text" name="adres" value='.$adres.'>
它只显示提交值的第一个单词。
(请注意,这类似于确认检查 实际数据已经以不同的形式发送)
尽管如此,如果我回显$adres; (我将它从表单中回显出来,只是为了检查 $_POST 是否具有正确的值)它只会显示所有内容,而如果我在输入值中这样做,它只会显示第一个单词
我真的不知道为什么会这样,而且似乎找不到解决方法。
<?php
$postcode = $_POST['postcode'];
$email = $_POST['email'];
$naam = $_POST['naam'];
$commentaar = $_POST['comment'];
$plaats = $_POST['woonplaats'];
$adres = $_POST['adres'];
echo '<h3>Factuur Gegevens</h3>
<section>
<label class="label">Naam: </label>
<label class="input">
<i class="icon-append fa-user"></i>
<input type="text" name="naam" value='.$naam.'>
</label>
</section>
<section>
<label class="label">Adres: </label>
<label class="input">
<i class="icon-append fa-home"></i>
<input type="text" name="adres" value='.$adres.'>
</label>
</section>
<div class="row">
<section class="col col-8">
<label class="label">Woonplaats: </label>
<label class="input">
<input type="text" name="woonplaats" value='.$plaats.'>
</label>
</section>
<section class="col col-4">
<label class="label">Postcode: </label>
<label class="input">
<input type="text" name="postcode" value='.$postcode.'>
</label>
</section>
</div>
<section>
<label class="label">Email: </label>
<label class="input">
<i class="icon-append fa-envelope"></i>
<input type="text" name="email" value='.$email.'>
</label>
</section>
<section>
<label class="label">Comment</label>
<label class="textarea">
<i class="icon-append fa-comments"></i>
<textarea rows="4" name="comment" >'. $commentaar .'</textarea>
</label>
</section>';
function emailcheck(){
global $email;
if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "Yay valid email <br>";
}
else {
echo " booh, wrong email :c";
}
}
function postcodecheck() {
global $postcode;
if(preg_match('/^[1-9]{1}[0-9]{3}[[:space:]]?[a-z]{2}$/i', $postcode)) {
echo "<br> Yay, valid postcode ( $postcode )";
}
else {
echo "Booh, wrong postcode :c";
}
}
?>
结果如下http://i.imgur.com/mvl2jLq.png
有人可以帮我吗? 乔迪
【问题讨论】:
-
您是否启用了
register_globals?你能展示你完整的PHP代码吗?当你print_r($_POST);时你看到了什么? -
请详细发布代码..
-
添加了在输入值中插入数据的脚本。
-
在文本框值周围添加双引号
-
@user3122479:生成后的 HTML 是什么样子的? (不含PHP代码,实际内容)