Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么HTML输入元素ID属性值在我发送电子邮件的表单中有前缀?_Php_Html_Forms_Html Email - Fatal编程技术网

Php 为什么HTML输入元素ID属性值在我发送电子邮件的表单中有前缀?

Php 为什么HTML输入元素ID属性值在我发送电子邮件的表单中有前缀?,php,html,forms,html-email,Php,Html,Forms,Html Email,我正在使用PHP编写一个HTML表单,通过电子邮件发送。例如,我有如下代码: $userOutput .= '<input type="hidden" id="seenUser" name="seenUser" value="'.$lastUsername.'">'; $userOutput .= '<input type="hidden" id="seenToken" name="seenToken" value="'.$userToken.'">'; 。。。由于前缀

我正在使用PHP编写一个HTML表单,通过电子邮件发送。例如,我有如下代码:

$userOutput .= '<input type="hidden" id="seenUser" name="seenUser" value="'.$lastUsername.'">';
$userOutput .= '<input type="hidden" id="seenToken" name="seenToken" value="'.$userToken.'">';
。。。由于前缀不可预测,这显然是失败的

长版本

这是我的网络邮件中显示的表单。显然,
onSubmit
是我的网络邮件提供商添加的。似乎可以合理地得出结论,对
表单
id
值的更改,以及我的问题中的
输入
id
值的更改,也可能是由web邮件提供商修改的

<form id="x_-381141859birdsSeen" action="https://www.MYDOMAIN.com.au/MYPAGE.php" method="post" onsubmit="return window.confirm(&quot;You are about to send information to an external page. Do you want to continue?&quot;);" target="_blank">
    <h4>Pacific Baza <input type="checkbox" name="pacbaz1" value="pacbaz1"></h4>
    2019-10-23 - <a href="https://www.OBFUSCATED.org/" target="_blank">AU-NSW-KRG</a>
    <br>
    <h4>Whiskered Tern <input type="checkbox" name="whiter2" value="whiter2"></h4>
    2019-10-22 - <a href="https://www.OBFUSCATED.org/" target="_blank">AU-NSW-NEW</a>
    <br>
    <input type="hidden" id="x_-381141859seenUser" name="seenUser" value="OBFUSCATED">
    <input type="hidden" id="x_-381141859seenToken" name="seenToken" value="8c1865d190e5a11d2cfe548224bf8d56">
    <input type="submit" value="Seen them!">
</form>
为什么id属性值有前缀
x_683480324

通过查看
表单
元素的完整代码,很明显表单中还添加了其他内容。其中一个(onSubmit的
onSubmit
属性)特别指出,是web邮件客户端做出了特定的更改,因此,可能其他客户端也做出了更改

由于前缀不可预测,这显然是失败的

一位评论员指出,代码不可能因为
id
属性而失败,因为
isset
name
属性进行操作,这些属性保持不变


关于代码在这一点上失败的原因,还没有解决方案。根据问题中的示例,处理这两种情况的变通方法-
isset
处理
name
值和/或
id
值-有效。

您是否有手动编码的
的其他实例(即没有框架)。它查看MySQL结果集数组,并为每个结果以字符串形式构建此表单的副本。包含整个表单的字符串被放入数组中。稍后,代码迭代该数组,并为每个元素准备和发送电子邮件。实际上,在处理PHP时,可能存在多个ID为“seenUser”的输入元素,但仅作为字符串内容存在。但是,在生成的每封电子邮件中,该ID应该只存在一次。电子邮件客户端是Zoho web mail。“…由于前缀不可预测,这显然是失败的。”-ID与此有什么关系?表单提交参数名称基于输入字段的名称,而不是ID,根据您向我们展示的内容,这些名称看起来没有变化。@04FS我希望不是因为这个原因您投了反对票?不管最后一句话如何,问题仍然存在:为什么要修改ID值?不过,在通过
foreach($\u POST as$postName=>$postValue)
遍历发布的参数后,检查是否有
$postName
seenUser
seenToken
结尾且分别明显长于8和9个字符的参数,代码输入了我的条件语句,但当按照我的问题中给出的代码进行编码时,它不会。尽管有相反的文件,这是我观察到的。
if (isset($_POST['seenUser'])&&isset($_POST['seenToken'])) {
<form id="x_-381141859birdsSeen" action="https://www.MYDOMAIN.com.au/MYPAGE.php" method="post" onsubmit="return window.confirm(&quot;You are about to send information to an external page. Do you want to continue?&quot;);" target="_blank">
    <h4>Pacific Baza <input type="checkbox" name="pacbaz1" value="pacbaz1"></h4>
    2019-10-23 - <a href="https://www.OBFUSCATED.org/" target="_blank">AU-NSW-KRG</a>
    <br>
    <h4>Whiskered Tern <input type="checkbox" name="whiter2" value="whiter2"></h4>
    2019-10-22 - <a href="https://www.OBFUSCATED.org/" target="_blank">AU-NSW-NEW</a>
    <br>
    <input type="hidden" id="x_-381141859seenUser" name="seenUser" value="OBFUSCATED">
    <input type="hidden" id="x_-381141859seenToken" name="seenToken" value="8c1865d190e5a11d2cfe548224bf8d56">
    <input type="submit" value="Seen them!">
</form>
foreach($_POST as $postName=>$postValue) {

    echo 'PostVar: '.$postName.'<br />';

    if (substr($postName, -8)==='seenUser'&&strlen($postName)>8) { // The POST variable name is longer than 8 chars and the last 8 chars are 'seenUser'
        $postedSeenUser = $postValue; // assign the convoluted variable's value to our nice simple name
    }

    if (substr($postName, -9)==='seenToken'&&strlen($postName)>9) { // The POST variable name is longer than 9 chars and the last 9 chars are 'seenToken'
        $postedSeenToken = $postValue; // assign the convoluted variable's value to our nice simple name
    }

    if ($postName==='seenUser') $postedSeenUser = $postValue;   // Just in case the variable arrives with nice clean name as desired
    if ($postName==='seenToken') $postedSeenToken = $postValue; // Just in case the variable arrives with nice clean name as desired

} // And now our variables should contain nice neat seenUser and seenToken values if they existed in some convoluted manner.

if (isset($postedSeenUser)&&isset($postedSeenToken)) {
if (isset($_POST['seenUser'])&&isset($_POST['seenToken'])) {