使用字符串引用时,只有在HTML表单中出现字符串的第一个字 [英] Only first word of string appearing in HTML form when using string-reference

查看:168
本文介绍了使用字符串引用时,只有在HTML表单中出现字符串的第一个字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我试图让表单文本字段的默认值为预定义的字符串。为此,我使用了一个参考。但是,无论何时我尝试使用PHP或任何类型的形式或形式的引用将表单中的字符串放入表单中,只会添加第一个单词。



以下是描述情况的图片: $ b



有谁知道为什么会发生这种情况,和/或解决办法这个问题?



实际的代码:

 <?php 
Echo< input type = \text \name = \Address \value = \one two three \>< br>;
?>

<?php
$ str =一二三;
Echo< input type = \text \name = \Address \value =。 $ str。 ><峰; br> 中;
?>

< input type =textname =Addressvalue =<?php echoone two three;?>>< br>
< input type =textname =Addressvalue =<?php $ str =one two three; echo $ str;?>>< br>
< input type =textname =Addressvalue =one two three>< br>


解决方案

您不引用回显的单词。
基本上你这样做:

 < input type =textvalue = one two three /> 

但您需要这样做:

 < input type =textvalue =one two three/> 

只需在PHP周围添加。

顺便说一句:如果你不想获得XSS,你需要逃避这些。这些攻击非常可怕。在这里阅读: https://www.owasp.org/index.php / Cross-site_Scripting_(XSS)


I'm having a problem with a HTML form and php.

I'm trying to make the default-value of a form-text field to be a pre-defined string. For this I'm using a reference. However, whenever I try to place a string into the form using PHP or references in any kind shape or form, only the first word gets added.

Here is a picture to describe the situation:

Does anyone know why this is happening, and/or a way to work around this issue?

Actual code:

<?php 
    Echo "<input type=\"text\" name=\"Address\" value=\"one two three\"><br>";
?>

<?php 
    $str ="one two three";
    Echo "<input type=\"text\" name=\"Address\" value=" . $str . "><br>";
?>

<input type="text" name="Address" value=<?php echo "one two three";?>><br>
<input type="text" name="Address" value=<?php $str = "one two three"; echo $str;?>><br>
<input type="text" name="Address" value="one two three"><br>

解决方案

You don't quote the echoed words. Basically you do this:

<input type="text" value=one two three />

But you need to do that:

<input type="text" value="one two three" />

Just add "" around the PHP.

BTW: You need to escape these if you don't want to get XSSed. These attacks are quite scary. Read about it here: https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)

这篇关于使用字符串引用时,只有在HTML表单中出现字符串的第一个字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆