在隐藏式文本区域中,我们可以在值字段中给出函数。
任何人都可以解释以下两行有什么作用吗?
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"NVOAction\" VALUE=\"Authenticate()\">\n";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"NVORedirect\" VALUE=\"redirectwebsite.com\">\n";
以下是完整的代码。
echo "<HTML>\n";
echo "<HEAD>\n";
echo "<TITLE>Name</TITLE>\n";
echo "<META http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n";
echo "<META NAME=\"pragma\" CONTENT=\"no-cache\">\n\n";
echo "</HEAD>\n";
echo "<BODY bgcolor=\"#FFFFFF\" text=\"#000000\" onLoad=\"javascript:document.nvoForm.submit();\">\n\n";
echo "<FORM NAME=\"nvoForm\" METHOD=\"POST\" ACTION="website.com">\n";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"NVOAction\" VALUE=\"Authenticate()\">\n";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"NVORedirect\" VALUE=\"redirectwebsite.com\">\n";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"NVOTarget\" VALUE=\"_top\">\n";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"nssaccount\" VALUE="account">\n";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"nssuser\" VALUE="user">\n";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"nsspassword\" VALUE="pass">\n";
echo "</FORM>\n\n";
echo "</BODY>\n";
echo "</HTML>\n";
答案 0 :(得分:1)
如果我理解正确并且你的函数返回一个字符串,你就能做到:
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"NVOAction\" VALUE=\"".Authenticate()."\">\n";
注意:
正如你可以看到SO的代码突出显示,你有几行可能会破坏,因为你没有转义你的属性引用,例如在这一行:
echo "<FORM NAME=\"nvoForm\" METHOD=\"POST\" ACTION="website.com">\n";
需要:
echo "<FORM NAME=\"nvoForm\" METHOD=\"POST\" ACTION=\"website.com\">\n";
<强>更新强> 我重新阅读了你的问题,所以这里是我答案的更新。
// This line will (when fixed according to above) create an HTML form input,
// and give it the value of whatever is returned by the Authenticate() method
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"NVOAction\" VALUE=\"Authenticate()\">\n";
// This line will create an HTML form input and give it the
// value of redirectwebsite.com
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"NVORedirect\" VALUE=\"redirectwebsite.com\">\n";