-4

お問い合わせフォームのhtmlページとその下のphpコードの私のhtmlコーディング

<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 ファイル

<?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 ='it@reverseinformatics.com';
$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>';
}
?>

上記は私のコードです。サイトでホストしているため、問題を克服するのに役立ちます。ローカルサーバーではうまく機能しますが、ウェブサイトでは機能しません

4

2 に答える 2