php
2013-04-14 192 views 0 likes 
0

我已經設置了一個表單,當按下圖像提交按鈕時,它將填充表單發送到商業電子郵件。PHP郵件腳本沒有發送到我的電子郵件

這裏是我用於從我的HTML鏈接的腳本。

<?php 
if(isset($_POST['submit'])) { 
$emailbody = 'First Name = '.$_POST['Name']."\n" 
.'Surname = '.$_POST['SName']."\n" 
.'Email = '.$_POST['email']."\n" 
.'Contact Number = '.$_POST['tel_no']."\n" 
.'Adress Line 1 = '.$_POST['address_line_1']."\n" 
.'Adress Line 2 = '.$_POST['address_line_2']."\n" 
.'Town/City = '.$_POST['town_city']."\n" 
.'County = '.$_POST['county']."\n" 
.'Post Code = '.$_POST['Post_code']."\n" 
.'Newsletter = '.$_POST['newsletter']."\n" 
.'Events = '.$_POST['events']."\n" 
mail('My [email protected]', 'Order Form', $emailbody); 

    } else { 
header('location: Payment.html'); 
    } 
?> 

html上的表單已通過操作鏈接。腳本有什麼問題嗎?

PS按下圖片後,它被轉發到PayPal付款頁面。

乾杯

編輯: 下面是HTML代碼:

<form name="form1" method="post" action="PaymentFormmail.php" align="left"> 
    <section> 
    <h1>Basic Infomation:</h1> 
    <p> 
    <label for="SName">First Name:</label> 
    <input type="text" name="Name" id="Name" style="margin-left:50px;"> 
    </p> 
    <p> 
    <label for="SName">Surname:</label> 
    <input type="text" name="SName" id="SName" style="margin-left:64px;"> 
    </p> 
    <p> 
     <label for="email">Email Address</label> 
     <input type="text" name="email" id="email" style="margin-left:28px;"> 
    </p> 
    <p> 
    <label for="tel_no">Contact Number:</label> 
    <input type="text" name="tel_no" id="tel_no" style="margin-left:14px;"> 
    </p> 
</section> 
<section> 
<h1>Billing Infomation:</h1> 
    <p> 
    <label for="address_line_1">Address line 1:*</label> 
    <input name="address_line_1" type="text" id="address_line_1" align="right" style="margin-left:20px;"> 
    </p> 
    <p> 
    <label for="address_line_2">Address Line 2: </label> 
    <input type="text" name="address_line_2" id="address_line_2"style="margin-left:20px;"> 
    </p> 
    <p> 
    <label for="town_city">Town/City:*</label> 
    <input type="text" name="town_city" id="town_city"style="margin-left:55px;"> 
    </p> 
    <p> 
    <label for="county">County:*</label> 
    <input type="text" name="county" id="county"style="margin-left:73px;"> 
    </p> 
    <p> 
    <label for="Post_code">Post Code:*</label> 
    <input type="text" name="Post_code" id="Post_code"style="margin-left:46px;"> 
    </p> 
<h1>News and Events:</h1> 
<p> 
    <input name="newsletter" type="checkbox" id="newsletter" value="Yes"> 
    <label for="newsletter">I wish to receive the monthly newsletter from Monster Computers UK</label> 
</p> 
<p> 
    <input name="events" type="checkbox" id="events" value="Yes"> 
    <label for="events">I wish to receive any infomation about upcomming events</label> 
</p> 

    </section> 
</form> 

<p>By Clicking Pay now you agree to the Terms of Service</p> 
        <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> 
        <input type="hidden" name="cmd" value="_xclick"> 
        <input type="hidden" name="business" value="[email protected]"> 
        <input type="hidden" name="lc" value="GB"> 
        <input type="hidden" name="item_name" id="byoName" value="0"> 
        <input type="hidden" name="amount" id="finalpaypal"> 
        <input type="hidden" name="currency_code" value="GBP"> 
        <input type="hidden" name="button_subtype" value="services"> 
        <input type="hidden" name="no_note" value="0"> 
        <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest"> 
        <input name="submit" type="image" onClick="MM_validateForm('Name','','R','SName','','R','email','','R','address_line_1','','R','town_city','','R','county','','R','Post_code','','R');return document.MM_returnValue" src="images/buttons/Pay Now.png" alt="PayPal — The safer, easier way to pay online." border="0"> 
        <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1"> 
        </form> 
+0

檢查表單操作並確保它設置爲POST。你的表單是否有一個名爲submit的元素,並且它是否有價值? – Robbert

+0

現在顯示html – user2057440

回答

0

嘗試改變

if(isset($_POST['submit'])) 

if(isset($_POST['SName'])) 

我認爲$ _ POST [ '提交' ]不起作用.. 如果這也失敗了,那麼這意味着信息不會發送到您的腳本。 在這種情況下,向我們顯示您在腳本中使用的表單的HTML。

編輯

Using if(isset($_POST['submit'])) to not display echo when script is open is not working

編輯時,HTML

你叫MM_validateForm JavaScript函數使用jQuery POST發送你的信息,你的郵件腳本,並刪除如果isset if子句檢查。

$.post("test.php", { name: "John", time: "2pm" }); 

http://api.jquery.com/jQuery.post/ 參見實施例部分。

+0

SName也沒有改變,請看鏈接ü給我加油吧 – user2057440

+0

已更新。第一種形式沒有提交輸入,因此信息不會發送到腳本。 –

相關問題