HTML HREF中的PHP不起作用
我在另一个php文件中打开“email.php”。 “email.php”会生成一个嵌入超链接的随机代码,但随机生成的代码未被插入。相反,字符串正在发送。功能randomCodeGenerator
的作品,并在util2.php
文件。HTML HREF中的PHP不起作用
<?php
require_once "inc/util2.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
<?php
$code = randomCodeGenerator(50);
?>
<p style="color: black;font-weight: bold;text-align: center;font-family: "Arial";">Hello! Thank you for your interest in Space Proposition!
For your account to become activated, please lease click the following link below to activate your email account:<br>
</p>
<a href="http://corsair.cs.iupui.edu:21221/upload/lab2/validateLab2.php?a=<?php echo $code;?>">
<p style="font-weight: bold;text-align: center;font-family: Arial;">Click Me!</p>
</a>
<br />
<p style="color: black;font-weight: bold;text-align: center;font-family: "Arial";">Once again, thank you very much for your interest. We will
do our best to keep the website updated regulary as new discoveries are made!<br>
</p>
</body>
</html>
当我点击发送给我的电子邮件中的链接,该超链接看起来是这样的:
http://corsair.cs.iupui.edu:21221/upload/lab2/validateLab2.php?a=%3C?phpecho%20$code;?%3E
file_get_contents
只是拉取文件的内容并将其存储到变量中。绕过PHP处理器,使用Web服务器来处理文件,然后你会得到结果。例如
file_get_contents('http://yourscript.php');
代替:
file_get_contents('/local/yourscript.php');
对于上述问题,此答案是? –
@Just_Do_It是的。 (虽然'file_get_contents'不在实际正在使用的注释中确定的问题的正文) – chris85
对不起,我错过了那部分。 –
试图改变你所添加的代码的方式,喜欢的东西:
$code = randomCodeGenerator(50);
$url = "http://corsair.cs.iupui.edu:21221/upload/lab2/validateLab2.php?a=".$code;
,最后;
<a href='<?php echo $url;?'>
您可以查看源?其他PHP块是否显示在那里?由于某种原因,它似乎并没有得到执行。 –
[如何在属性值内添加php标签?](https://stackoverflow.com/questions/14900370/how-to-add-php-tags-inside-attribute-value) – pvg
@ chris85'email .php'文件与访问它的文件位于同一个目录中。我正在使用'file_get_contents()'函数将'email.php'文件的内容打开成一个名为'$ body'的变量。然后我使用'mail/mail.class.php'库发送邮件。 – cparks10