0

私は、php 変数 (POST メソッドを使用してフォームで取得) を含む電子メールを送信する PHP スクリプトを使用しています。これは私のコードです:

<?php
/* These will gather what the user has typed into the fieled. */

$nameField = $_POST['name'];
$emailField = $_POST['email'];
$questionField = $_POST['question'];

/* These are the variable that tell the subject of the email and where the email will be sent.*/

$emailSubject = 'Recupero password LightSchool';
$mailto = $_POST['email'];
$mail->From = 'from@example.com';
$mail->FromName = 'Mailer';

/* This takes the information and lines it up the way you want it to be sent in the email. */

$body = '<br><hr><br> Name: '.$name.' <br> Email: '.$email.' <br> Question: '.$question.' <br>';

$headers = "From: $email\r\n"; // This takes the email and displays it as who this email is from.
$headers .= "Content-type: text/html\r\n"; // This tells the server to turn the coding into the text.
$success = mail($mailto, $emailSubject, $body, $headers); // This tells the server what to send.

?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head>  
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
    <title>MY Studenti</title>
    <link rel="stylesheet" href="style.css" type="text/css" />
    </head>  
    <body style="background-image:url(http://studenti.lightschool.it/new/bkg.png)">  
    <div id="main">
    <h1>
    <img src="http://images.lightschool.it/logo/medium250x250.png" alt="" height="66" style="float: left; margin-right: 20px" width="62" />MY Studenti</h1>
    <p>Recupera password ti permette di recuperare la tua password, tramite 
    l'inserimento del tuo nome utente.</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <form id="form1" name="form1" method="post" action="reset-pwd.php">
<table width="455" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="175" height="44" align="center"><label for"name">name</label></td>
    <td width="280"><input name="name" type="text" id="name" size="30" />
      </td>
  </tr>
  <tr>
    <td height="45" align="center"><label for="email">email</label></td>
    <td><input name="email" type="text" id="email" size="30" /></td>
  </tr>
  <tr>
    <td height="41" align="center"><label for="question">question</label></td>
    <td><textarea name="question" cols="30" rows="5" id="question"></textarea></td>
  </tr>
  <tr>
    <td height="38">&nbsp;</td>
    <td><label>
      <input type="submit" name="Submit" id="Submit" value="Submit" />
    </label></td>
  </tr>
</table>

</form>
    </div>
    </body>
    </html>

この PHP スクリプトは正常に実行されますが、送信された電子メールに表示されない 3 つの変数 (名前、電子メール、および質問) があります。これも解決せずに試しましたvar_dump($_POST['email']);。どうすればこの問題を解決できますか?

ありがとう。

PS: この Web サイトや他のサイトに投稿されたこの質問がたくさんあることは知っていますが、これらの投稿された解決策はどれも役に立ちませんでした。

4

2 に答える 2

4

変化する

$nameField = $_POST['name'];
$emailField = $_POST['email'];
$questionField = $_POST['question'];

$name = $_POST['name'];
$email = $_POST['email'];
$question = $_POST['question'];
于 2013-03-28T14:37:06.847 に答える
1

Vars を 2 つの異なるものと呼んでいます。これには気をつけたいと思います。誰の電子メールも除外していない場合、誰かがアドレスのリストをフィードして、あなたのボックスからスパムを送信し始める可能性があります。

于 2013-03-28T14:39:51.343 に答える