我有一个名为contact.php的文件,里面有表格:
<form method="post" name="kontakt" action="send_mail.php">
<fieldset class="formularz_kontaktowy">
<legend>Formularz kontaktowy</legend>
<div><label id="lblStatus"></label></div>
<div><input type="text" name="txtName" title="Imię i nazwisko" id="txtName" class="text"></div>
<div><input type="text" name="txtEmail" title="Email" id="txtEmail" class="text"></div>
<div><input type="text" name="txtTitle" title="Tytuł" id="txtTitle" class="text"></div>
<div><textarea cols="30" rows="10" name="txtMessage" id="txtMessage" class="text" title="Treść wiadomości"></textarea></div>
<input type="submit" name="btnSendmail" value=Send">
</fieldset>
</form>
在浏览器中单击 btnSendmail 后,我有 URL,例如:localhost/contact.php?txtName=Mary+Smith&txtEmail=mailMail%40gmail.com&txtTitle=dfd&txtMessage=fgdf&btnSendmail=Send,但我认为应该是 localhost/send_mail.php。它的原因是什么?
编辑:send_mail.php
<?php
require_once "Mail.php";
$from = "<mailaddress@gmail.com>";
$to = "<mail2@gmail.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "<mailaddress@gmail.com>";
$password = "password";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>