2016-12-15 72 views
-1

我已经创建了一个表单。用户将提交表单并将获得链接的电子邮件。点击链接后,我必须在URL上显示ID,你能帮我吗?如何在点击链接在PHP后显示URL上的ID?

if (isset($result->num_rows) > 0) { 
    while($row = $result->fetch_assoc()) { 
     $User_id = $row['User_id']; 
     }} 

    echo $User_id;// I am able to display id here 

    $message = " 
    <html> 
    <head> 
    <title>HTML email</title> 
    </head> 
    <body> 
    <a href='http://localhost/in/abc.php?user_id='" .$User_id. ">Click here</a> 
    </body> 
    </html> 
    "; 

我的URL获得输出

http://localhost/in/abc.php?user_id= 
+0

你在工作的首位使用“$ USER_ID”,但随后被之后使用“$ User_id ** 1 **”。 – Iskar

回答

1

您需要修改你的代码使用的是两个变量,而您也缺少引号`

<a href='http://localhost/in/abc.php?user_id='" .$User_id1. ">Click here</a> 

<a href='http://localhost/in/abc.php?user_id=" .$User_id."'>Click here</a> 

应该是,

$message = " 
     <html> 
     <head> 
     <title>HTML email</title> 
     </head> 
     <body> 
     <a href='http://localhost/in/abc.php?user_id=".$User_id."'>Click here</a> 
     </body> 
     </html>"; 
+0

为什么你在做''。$ user_ud。“'? – Option

+0

抱歉,错字。在href值结束时需要引用。 – ScanQR

+0

是的工作..谢谢Mr.ScanQR –

2

我最好的只是完成:

echo $User_id;// I am able to display id here 

    $message = " 
     <html> 
     <head> 
     <title>HTML email</title> 
     </head> 
     <body> 
     <a href='http://localhost/in/abc.php?user_id='$User_id1'>Click here</a> 
     </body> 
     </html> 
     "; 

你不需要Concat的的?user_id='$User_id1'>

+0

这也适用于我。谢谢Mr.Option –

相关问题