我哥哥有這種形式:PHP代碼適用於Chrome,但不能在Firefox或IE
<form id="lista" action="lista2.php" method="post">
<input name="cf_name" type="text" size="50" hidden="yes" class="obscure">
<input name="cf_email" type="text" size="50" hidden="yes" class="obscure">
<textarea name="cf_message" cols="45" rows="10" hidden="yes" class="obscure">
</textarea>
<input type="image" name="submit" value="Enviar Lista por Email" src="imagens/lista_email.png" width="40" height="40"
onclick="this.form.elements['cf_message'].value = lista_mail;this.form.elements['cf_name'].value = prompt('Escreva o seu nome:', '');this.form.elements['cf_email'].value = prompt('Escreva o seu email:', '');">
<input name="submit2" type="submit" value="Enviar" hidden="yes" class="obscure">
</form>
調用此PHP文件:
<?php
if (isset($_POST['submit'])) {
// Dados de autenticacao SMTP
$smtpinfo['host'] = 'localhost';
$smtpinfo['port'] = '25';
$smtpinfo['auth'] = true;
$smtpinfo['username'] = 'xxx';
$smtpinfo['password'] = 'xxx';
// Dados recebidos do formulario
$nome = $_POST['cf_name'];
$email = $_POST['cf_email'];
$mensagem = $_POST['cf_message'];
// Inclusão de ficheiro PEAR. Certifique-se que o PEAR está activado no seu alojamento
require_once "Mail.php";
// Corpo da mensagem
$body = "Nome: ".$nome;
$body.= "\n\n";
$body.= nl2br($mensagem);
$headers = array ('From' => $email,
'To' => $smtpinfo["username"],
'Subject' => 'Encomenda Website');
$mail_object = Mail::factory('smtp', $smtpinfo);
$mail = $mail_object->send($smtpinfo["username"], $headers, $body);
if (PEAR::isError($mail)) {
echo ("<p>" . $mail->getMessage() . "</p>");
} else {
echo ('<b><font color="FFFF00">Mensagem enviada com sucesso.<br><br></b>Seu email: ' . $email . '<br><br></font>');
}}
?>
這基本上發送電子郵件與一些選定的產品,名稱和電子郵件。
問題是,它可以在Chrome上完美工作,但不能在FF或IE上運行。當按下提交圖像時,URL將更改爲PHP文件,但顯示空白頁面。
編輯:
將此添加:
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1)
FF/IE顯示空白頁和電子郵件不被髮送,瀏覽器發送的電子郵件,並顯示此:
Strict Standards: Non-static method Mail::factory() should not be called statically in /var/www/vhosts/[site url]/httpdocs/lista2.php on line 33
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /usr/share/php/Mail/smtp.php , dont know if it helps
關於「隱藏」字段的提示也沒有幫助。
打開錯誤。會有一些警告或錯誤。 – MahanGM
嘗試使用'type =「hidden」' – aldanux
替換'hidden =「yes」',以及爲什麼'textarea'隱藏或'class =「遮擋」'? – aldanux