Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
665 views
in Technique[技术] by (71.8m points)

php - Contact us mail error

My html coding for the contact form html page and below that is the php code

<form name="form1" method="post" action="contact.php" id="contactform">
                                <table width="100%" border="0" cellspacing="1" cellpadding="3">
                                    <tr>
                                        <td><input name="name" type="text" id="name" ONFOCUS="clearDefault(this)" value="Name" size="90" style="background: #DAEDFF; border:1px solid #DAEDFF; border-radius:3px; height: 25px;"></td>
                                    </tr>
                                    <tr>
                                        <td><input name="customer_mail" type="text" value="Email" ONFOCUS="clearDefault(this)" id="customer_mail" size="90" style="background: #DAEDFF; border:1px solid #DAEDFF; border-radius:3px; height: 25px;"></td>
                                    </tr>
                                    <tr>
                                        <td width="82%"><input name="subject" type="text" value="Subject" ONFOCUS="clearDefault(this)" id="subject" size="90" style="background: #DAEDFF; border:1px solid #DAEDFF; border-radius:3px; height: 25px;"></td>
                                    </tr>
                                    <tr>
                                        <td><textarea name="detail" cols="90" rows="8" id="detail" style="background: #DAEDFF; border:1px solid #DAEDFF; border-radius:3px;"></textarea></td>
                                    </tr>
                                    <tr>
                                        <td style="padding-left: 530px;"><input type="submit" name="Submit" value="Send" style="background: #1B99E8; border: 1px solid #1B99E8; color: #ffffff; border-radius:3px;"></td>
                                    </tr>
                            </table>
                        </form>

contact.php file

<?php

$subject        =   $_POST['subject'];
$detail         =   $_POST['detail'];
$customer_mail  =   $_POST['customer_mail'];
$name           =   $_POST['name'];

// Contact subject
$subject ="$subject"; 

// Details
$message="$detail";

// Mail of sender
$mail_from="$customer_mail"; 

// From 
$header="from: $name <$mail_from>";

// Enter your email address
$to ='[email protected]';
$send_contact=mail($to,$subject,$message,$header);

// Check, if message sent to your email 
// display message "We've recived your information"
if($send_contact){
echo '<script language="javascript">confirm("We have received your request, our team will contact you shortly.")</script>';
echo '<script language="javascript">window.location = "contact.html"</script>';
}
else {
echo '<script language="javascript">confirm("Oops Sorry for the inconvinience.")</script>';
echo '<script language="javascript">window.location = "contact.html"</script>';
}
?>

Above is my code plz help me to overcome my problem since i have hosted in the site, it works well in my local server but not working in the website

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I guess thee is problem with your code at window.location = "contact.html" part. If you want to redirect to this page, try giving absolute path. You may also try window.location.href or window.open. Note that window.open will open it in new window.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...