目标是在单击按钮时调用变量$ url。使用当前的代码,当单击按钮时没有任何反应,错误表示意外的令牌。
<?php
$url = "edit_beginningcakephp.php?title=$title&author=$author&isbn=$isbn
&year=$year&pages=$pages&price=$price";
>?
<input type="button" value="Edit Book" onclick="window.location.href='<?= $url ?>'">
答案 0 :(得分:1)
我认为你没有正确编码变量的内容(称为XSS)
您需要urlencode变量的内容。此外,&
需要作为HTML实体&
输入。
尝试:
$url = 'edit_beginningcakephp.php?title='.urlencode($title).'&author='.urlencode($author).'&isbn='.urlencode($isbn).'&year='.urlencode($year).'&pages='.urlencode($pages).'&price='.urlencode($price);
PS:>?
应为?>
,并确保该网址不包含任何换行符。
答案 1 :(得分:0)
&#34; &GT ;? &#34; 看起来这可能是一个问题,肯定会在我的本地抛出语法错误:)
答案 2 :(得分:0)
虽然MrTux的答案非常好,并且肯定会遵循他的建议,但代码的实际问题是URL中的返回。 URLS不能包含退货!
解决方案:删除退货。和空间。并按照MrTux的建议。