0
我在窗體的動作標籤中寫入'#',然後包含一個php腳本以在點擊提交按鈕時執行動作。頁面重定向動作標籤
HTML代碼:
<form id="newsletter" method="post" action="#">
<div class="input-group">
<label class="sr-only" for="news">Full Name</label>
<input type="email" id="news" name="news" class="form-control" placeholder="E-Mail Address" required>
<span class="input-group-btn">
<button class="btn btn-default" type="submit" name="submit">Subscribe</button>
</span> </div>
</form>
<?php include "newsletter.php"?>
我想,一旦工作完成索引頁被重定向到一個不同的頁面。標題[位置]似乎不起作用,因爲它給出了已經發送的頭的錯誤。
PHP代碼:
<?php
if($_POST){
$email = $_POST["news"];
$subject = "New Subscribe for Newsletter";
$message = "<b>From : ".$email."</b><br/>";
$message = "<b>Subscriber from mailnews: $email</b>";
$from = "[email protected]";
$to = "[email protected]";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: MailNews<'.$to.'>' . "\r\n";
$headers .= 'From: Contacted from <'.$from.'>' . "\r\n";
mail($to, $subject, $message, $headers);
?>
<?php }
?>
你的php代碼在哪裏 –
可能的[如何修復]已經發送的頭文件「PHP中的錯誤」的副本(http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent- error-in-php) –
php代碼按要求添加 –