我試圖重新向您發送包含用戶的用戶名和密碼的電子郵件,但是用戶名不經歷,而密碼爲。PHP變量不傳遞給電子郵件
PHP:
<?php
if(!isset($_POST['submit']))
$user = $_POST['username'];
$pass = $_POST['password'];
$email = $_POST['email'];
$email_from = '[email protected]';
$email_subject = "Username and Password for you";
$email_body = "Username: $user \n".
"Password: $pass \n".
$to = $email;
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_from \r\n";
mail($to,$email_subject,$email_body,$headers);
?>
HTML:
<!DOCTYPE html>
<html>
<head>
<title>Login Form in PHP with Session</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<form action="db.php" method="post">
First name:<br>
<input type="text" name="username" readonly value='<?php echo $random_first .'_'. $random_second; ?>'><br>
Last name:<br>
<input type="text" name="password" readonly value='<?php echo $pw; ?>'><BR>
Enter your email to get a copy of these!<br>
<input type="text" name="email"><BR>
<input type ="submit" value = "submit" name="submit">
</form>
</body>
得到的電子郵件:
Username:
Password: hG31cZbTL
我現在很茫然。用戶名應該在表單中生成。我可能只是錯過了一些小東西,需要其他的眼睛才能看到它。
我有一個腳本,當頁面加載時會生成一個隨機的用戶名和密碼,因此用戶名和密碼值中的變量。他們相當長時間,並不認爲他們會涉及這個特殊問題,所以他們已經離開了他們。
確定'<?PHP的echo $ random_first .'_」。 $ random_second; ?>總是有價值?因爲其餘代碼看起來完全正常。 –
你可以在提交之前在'textbox'中看到值嗎? –
首先,你可以檢查的值'$ random_first,$ random_second' .show你的代碼提交 –