繁体   English   中英

HTML HREF中的PHP无法正常工作

[英]PHP in HTML HREF not working

我正在另一个PHP文件中打开“ email.php”。 “ email.php”生成随机代码以嵌套到超链接中,但是不会插入随机生成的代码。 而是发送文字字符串。 函数randomCodeGenerator可以使用,位于util2.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: &quot;Arial&quot;;">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: &quot;Arial&quot;;">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

尝试更改添加代码的方式,例如:

$code = randomCodeGenerator(50);
$url = "http://corsair.cs.iupui.edu:21221/upload/lab2/validateLab2.php?a=".$code;

最后;

<a href='<?php echo $url;?'>

file_get_contents只是提取文件的内容并将其存储到变量中。 这绕过了PHP处理器,使用Web服务器来处理文件,然后您将获得结果。 例如

file_get_contents('http://yourscript.php');

代替:

file_get_contents('/local/yourscript.php');

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM