簡體   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