繁体   English   中英

如何使div内容可下载到txt文件?

[英]How do i make div content downloadable to txt file?

我的网站为每个要登录的帐户生成唯一的密钥(密码)。 这是重要,机密且不可恢复的。 因此,如何使每个人都可以txt格式下载该文件。

这段代码:

echo '<h2>';
print "Welcome  $username  to your dashboard<br>";

}
echo "</h2>";
echo "<p>";

$sec_value = 'usqi3289';
$rdecrypted_text = mcrypt_ecb(MCRYPT_DES, $sec_value, $userkey, MCRYPT_DECRYPT); 

echo "<div class='button special'>Your Userkey: <font color='black'>$rdecrypted_text</font></div>";
?>
 <br><p align="center">Please save your Userkey first,This is confidential and unrecoverable, because we don't hold any passwords. </p>

主要是这个:

"<div class='button special'>Your Userkey: <font color='black'>$rdecrypted_text</font></div>"; ?>

我想要一个下面的按钮,以便人们单击它,它会下载一个包含此userkey的txt文件。

您可以将此代码放在一个PHP file ,例如userkeydl.php

<?php

    header("Content-type: text/plain");
    header("Content-Disposition: attachment; filename = userkey.txt");

    print "Your Userkey is: \n";
    print $rdecrypted_text;
    print "\nPlease note that this is confidential and unrecoverable.";

?>

暂无
暂无

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

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