簡體   English   中英

電子郵件表單的PHP問題

[英]PHP Issue with Email Form

我曾經在此網站上獲得過巨大成功,但在使用PHP電子郵件表單時遇到了類似的問題。 我嘗試從以前的表格復制來,該網站上的人對按照我想要的方式工作非常有幫助,但是由於某種原因,它不會發送該表格。 我確信這是一個愚蠢的疏忽,但希望您能多加注意。

這是代碼:

<?php
$state = 0;
// check to see if verificaton code was correct
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
// if verification code was correct send the message and show this page
mail("myemailaddress@hotmail.com", 'Website Inquiry: '.$subject, "\n".$comments." 
\n\n".$name."\n\n".$company."\n\n".$email."\n\n".$_SERVER['REMOTE_ADDR']."\n\n".'InterestedIn: '.$InterestedIn, "\n\n".'ContactMethod: '.$ContactMethod,"From: $email");
// delete the cookie so it cannot sent again by refreshing this page
setcookie('tntcon','');
$state = 2;
} else if(isset($message) and $message!=""){
// if verification code was incorrect then return to contact page and show error
$state = 1;
}

if ($state == 0) {  ?>
<form action="" method="post" name="form1" id="form1" 

onsubmit="MM_validateForm('email','','RisEmail','name','','R','verif_box','','R')

;return document.MM_returnValue">

 <p><strong>Tell us what you're interested in:</strong></p>
<dl>
    <dd><input type="radio" name="InterestedIn" value="BIBS<?php echo $_GET['InterestedIn'];?>"> Blow-In-Blanket System
    <input type="radio" name="InterestedIn" value="Foam<?php echo $_GET['InterestedIn'];?>"> Soya Spray Foam
    <input type="radio" name="InterestedIn" value="Attic<?php echo $_GET['InterestedIn'];?>"> Attic Insulation
    <input type="radio" name="InterestedIn" value="NotSure<?php echo $_GET['InterestedIn'];?>" checked="checked"> Not Sure</dd>
</dl>
<p><strong>Enter additional comments in the space provided below:</strong></p>
<dl>
    <dd><textarea name="comments" cols="50" rows="5" border="0" id="comments"><?php echo $_GET['comments'];?></textarea></dd>
</dl>
<p><strong>Tell us how to get in touch with you:</strong></p>
<dl>
    <dd>
    <table>
        <tr>
            <td>Name*</td>
            <td>
            <input type="text" size="40" maxlength="256" name="Name" value="<?php echo $_GET['name'];?>"></td>
        </tr>
        <tr>
            <td>Company</td>
            <td>
            <input type="text" size="40" maxlength="256" name="Company" value="<?php echo $_GET['company'];?>"></td>
        </tr>
        <tr>
            <td>Email*</td>
            <td><input type="text" size="40" maxlength="256" name="email" value="<?php echo $_GET['email'];?>"></td>
        </tr>
        <tr>
            <td>Phone</td>
            <td><input type="text" size="40" maxlength="256" name="Phone" value="<?php echo $_GET['phone'];?>"></td>
        </tr>
        <tr>
            <td>City</td>
            <td><input type="text" size="40" maxlength="256" name="City" value="<?php echo $_GET['city'];?>"></td>
        </tr>
    </table>
    </dd>
</dl>
    <p><strong>Best method to get in touch with you:</strong></p>

<dl>
    <dd><input type="radio" name="ContactMethod" value="byphone<?php echo $_GET['InterestedIn'];?>" checked="checked">  Phone
    <input type="radio" name="ContactMethod" value="byemail<?php echo $_GET['InterestedIn'];?>"> Email
    </dd>
</dl>

   <dl><dd><img src="verificationimage.php?<?php echo rand(0,9999);?>" alt="verification image, type it in the box" width="50" height="24" align="top"/>&nbsp;&nbsp;<input name="verif_box" type="text" id="verif_box" style="padding:2px; border:1px solid #CCCCCC; width:80px; height:14px;"/><br /><br />
Enter Verification Image

</dd></dl>


<p style="padding-left:60px;"><input type="submit" class="button primary" value="Submit Form" name="submit"/>
<input type="reset" class="button primary" value="Clear Form" name"clear" /></p>
</form>

任何幫助將不勝感激,因為我在家中有一個新嬰兒,並且非常渴望有時間成為新媽媽,並努力完成最后一個項目。

先感謝您!

我認為一些基本的調試會很有幫助。

  1. 您似乎在混用$_GETmethod='post'

  2. 嘗試一個僅用硬編碼值調用mail()單行腳本。 那樣有用嗎?

  3. 嘗試提交您的表格。 輸出$_POST 它具有您所期望的一切嗎? $_COOKIE嗎?

  4. 提前構造要傳遞給mail所有字符串。 他們每個人看起來像他們應該的嗎?

  5. 嘗試采用這些確切的字符串,然后將其直接放入mail() (如上面的#2)。 那樣有用嗎?

到此列表的末尾,您將知道失敗的位置,並可以獲得更具體的答案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM