2016-09-13 5 views
1

初めてのポスター、長時間の読者。このサイトは素晴らしかったですが、ついに私は自分の頭の中に自分自身を見つけました。 私は結果を私にメールするPHPスクリプトに送信するために基本的なフォームを書いています。 送信ボタンの単純な操作はありません。問題が何であるか把握できる人は誰ですか?フォームを提出できません(html、php)

ライブバージョンは、ここで見ることができます:ここhttp://adamgalushacsis310.com/contact.html

は私のコードです:PHPファイルと

/* links */ 
 
a:link {color: inherit; text-decoration: none;} 
 

 
a:visited {color: inherit; text-decoration: none;} 
 

 
a:hover {text-decoration: underline; font-weight: bold; color: inherit;} 
 

 
a:active {text-decoration: none; style: none;} 
 

 
/* body formatting */ 
 
body { 
 
\t background-color: white; 
 
\t color: black; 
 
\t } 
 
\t 
 
\t 
 
\t /*css styling for individual divs*/ 
 
.li { 
 
\t display: list-item; 
 
\t margin-left: 2em 
 
\t } 
 
\t 
 
.floatingbanner { 
 
\t float:right; 
 
\t padding-right:10px; 
 
\t padding-top:10px; 
 
} 
 
.floatingidtag { 
 
\t float:right; 
 
\t padding-right:10px; 
 
\t padding-top:10px; 
 
} 
 

 
#contactformcontainer{ 
 
\t text-align: center; 
 
} 
 
#contactform{ 
 
\t margin:auto; 
 
\t width: 100%; 
 
\t } 
 

 
#cfleft{ 
 
\t display: inline-block; 
 
\t text-align: left; \t 
 
\t } 
 

 
#cfright{ 
 
\t display: inline-block; 
 
\t text-align: left; 
 
\t } 
 

 
\t 
 
#header { 
 
\t margin:0px auto; 
 
\t width: 300px; 
 
\t } 
 

 
#menu { 
 
\t background-color: #f2f2f2; 
 
\t width: 100%; 
 
\t padding-left: 12.5% 
 
\t } 
 

 
#content{ 
 
\t background-color: #f2f2f2; 
 
\t width: 75%; 
 
\t margin: auto; 
 
\t padding: 10px; 
 
\t overflow:auto; 
 
\t } 
 

 
#aboutmeheaderplaceholder{ 
 
\t /* stil debating on using this or no*/ 
 
\t height: 250px; 
 
} 
 

 
#footer { 
 
\t background-color: #f2f2f2; 
 
\t width: 100%; 
 
\t clear:both; 
 
\t }
<!-- begin contact form --> 
 
\t \t \t <form action="http://adamgalushacsis310.com/form_send.php" method="post"> 
 
\t \t \t <div id="contactformcontainer"> 
 
\t \t \t \t <div id="contactform"> 
 
\t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t \t <div id="cfleft"> 
 
\t \t \t \t \t \t \t First Name:<BR> 
 
\t \t \t \t \t \t \t <input name="first_name" type="text" size="12"><BR> 
 
\t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t <div id="cfright"> \t \t \t \t 
 
\t \t \t \t \t \t \t Last Name:<BR> 
 
\t \t \t \t \t \t \t <input name="last_name" type="text" size="20"><BR> 
 
\t \t \t \t \t \t </div> 
 
\t \t \t \t </div> 
 
\t \t \t \t <BR> 
 
\t \t \t \t <div id="contactform"> 
 
\t \t \t \t \t <div id="cfleft"> 
 
\t \t \t \t \t \t Email Address:<BR> 
 
\t \t \t \t \t \t <input name="email" type="text" size="37"><BR> 
 
\t \t \t \t \t </div> 
 
\t \t \t \t </div> 
 
\t \t \t \t <br> 
 
\t \t \t \t <div id="contactform"> 
 
\t \t \t \t \t <div id="cfleft"> 
 
\t \t \t \t \t \t Address:<BR> 
 
\t \t \t \t \t \t <input name="address" type="text" size="37"><BR> 
 
\t \t \t \t \t </div> 
 
\t \t \t \t </div> 
 
\t \t \t \t <div id="contactform"> 
 
\t \t \t \t \t <div id="cfleft"> 
 
\t \t \t \t \t \t City:<br> 
 
\t \t \t \t \t \t <input name="city"type="text"> 
 
\t \t \t \t \t </div> 
 
\t \t \t \t \t <div id="cfright"> 
 
\t \t \t \t \t \t State:<BR> 
 
\t \t \t \t \t \t <select name="state" style="width:115px;"> 
 
\t \t \t \t \t \t \t <option value="AL">Alabama</option> 
 
\t \t \t \t \t \t \t <option value="AK">Alaska</option> 
 
\t \t \t \t \t \t \t <option value="AZ">Arizona</option> 
 
\t \t \t \t \t \t \t <option value="AR">Arkansas</option> 
 
\t \t \t \t \t \t \t <option value="CA">California</option> 
 
\t \t \t \t \t \t \t <option value="CO">Colorado</option> 
 
\t \t \t \t \t \t \t <option value="CT">Connecticut</option> 
 
\t \t \t \t \t \t \t <option value="DE">Delaware</option> 
 
\t \t \t \t \t \t \t <option value="DC">District Of Columbia</option> 
 
\t \t \t \t \t \t \t <option value="FL">Florida</option> 
 
\t \t \t \t \t \t \t <option value="GA">Georgia</option> 
 
\t \t \t \t \t \t \t <option value="HI">Hawaii</option> 
 
\t \t \t \t \t \t \t <option value="ID">Idaho</option> 
 
\t \t \t \t \t \t \t <option value="IL">Illinois</option> 
 
\t \t \t \t \t \t \t <option value="IN">Indiana</option> 
 
\t \t \t \t \t \t \t <option value="IA">Iowa</option> 
 
\t \t \t \t \t \t \t <option value="KS">Kansas</option> 
 
\t \t \t \t \t \t \t <option value="KY">Kentucky</option> 
 
\t \t \t \t \t \t \t <option value="LA">Louisiana</option> 
 
\t \t \t \t \t \t \t <option value="ME">Maine</option> 
 
\t \t \t \t \t \t \t <option value="MD">Maryland</option> 
 
\t \t \t \t \t \t \t <option value="MA">Massachusetts</option> 
 
\t \t \t \t \t \t \t <option value="MI">Michigan</option> 
 
\t \t \t \t \t \t \t <option value="MN">Minnesota</option> 
 
\t \t \t \t \t \t \t <option value="MS">Mississippi</option> 
 
\t \t \t \t \t \t \t <option value="MO">Missouri</option> 
 
\t \t \t \t \t \t \t <option value="MT">Montana</option> 
 
\t \t \t \t \t \t \t <option value="NE">Nebraska</option> 
 
\t \t \t \t \t \t \t <option value="NV">Nevada</option> 
 
\t \t \t \t \t \t \t <option value="NH">New Hampshire</option> 
 
\t \t \t \t \t \t \t <option value="NJ">New Jersey</option> 
 
\t \t \t \t \t \t \t <option value="NM">New Mexico</option> 
 
\t \t \t \t \t \t \t <option value="NY">New York</option> 
 
\t \t \t \t \t \t \t <option value="NC">North Carolina</option> 
 
\t \t \t \t \t \t \t <option value="ND">North Dakota</option> 
 
\t \t \t \t \t \t \t <option value="OH">Ohio</option> 
 
\t \t \t \t \t \t \t <option value="OK">Oklahoma</option> 
 
\t \t \t \t \t \t \t <option value="OR">Oregon</option> 
 
\t \t \t \t \t \t \t <option value="PA">Pennsylvania</option> 
 
\t \t \t \t \t \t \t <option value="RI">Rhode Island</option> 
 
\t \t \t \t \t \t \t <option value="SC">South Carolina</option> 
 
\t \t \t \t \t \t \t <option value="SD">South Dakota</option> 
 
\t \t \t \t \t \t \t <option value="TN">Tennessee</option> 
 
\t \t \t \t \t \t \t <option value="TX">Texas</option> 
 
\t \t \t \t \t \t \t <option value="UT">Utah</option> 
 
\t \t \t \t \t \t \t <option value="VT">Vermont</option> 
 
\t \t \t \t \t \t \t <option value="VA">Virginia</option> 
 
\t \t \t \t \t \t \t <option value="WA">Washington</option> 
 
\t \t \t \t \t \t \t <option value="WV">West Virginia</option> 
 
\t \t \t \t \t \t \t <option value="WI">Wisconsin</option> 
 
\t \t \t \t \t \t \t <option value="WY">Wyoming</option> 
 
\t \t \t \t \t \t </select><BR> 
 
\t \t \t \t \t </div> 
 
\t \t \t \t </div> 
 
\t \t \t \t <br> 
 
\t \t \t \t <div id="contactform"> 
 
\t \t \t \t \t <div id="cfleft"> 
 
\t \t \t \t \t \t Phone Number: <BR> 
 
\t \t \t \t \t \t <input name="phone" type="tel" placeholder="xxx-xxx-xxxx"><BR> 
 
\t \t \t \t \t </div> 
 
\t \t \t \t \t <div id="cfright"> 
 
\t \t \t \t \t \t Availability:<BR> 
 
\t \t \t \t \t \t <select name="availability> 
 
\t \t \t \t \t \t \t <option value="Morning">Morning</option> 
 
\t \t \t \t \t \t \t <option value="Afternoon">Afternoon</option> 
 
\t \t \t \t \t \t \t <option value="Evening">Evening</option> 
 
\t \t \t \t \t \t </select><BR> 
 
\t \t \t \t \t </div> 
 
\t \t \t \t </div> 
 
\t \t \t \t <br> 
 
\t \t \t \t <div id="contactform"> 
 
\t \t \t \t \t <div id="cfleft"> 
 
\t \t \t \t \t \t I am interested in contact for the following reason(s):<BR> 
 
\t \t \t \t \t \t <input type="checkbox" name="reason1" value="employment_interest">Employment Interest 
 
\t \t \t \t \t \t <input type="checkbox" name="reason2" value="consultation">Consultation 
 
\t \t \t \t \t \t <input type="checkbox" name="reason3" value="">Other<BR> 
 
\t \t \t \t \t </div> 
 
\t \t \t \t </div> 
 
\t \t \t \t <div id="contactform"> 
 
\t \t \t \t \t <div id="cfleft"> 
 
\t \t \t \t \t \t <BR><textarea name="reason_other" rows="4" cols="40" placeholder="If Other, please explain."></textarea> 
 
\t \t \t \t \t </div> 
 
\t \t \t \t </div> 
 
\t \t \t \t <div id="contactform"> 
 
\t \t \t \t \t <div id="cfleft"> 
 
\t \t \t \t \t \t <BR><input type="submit" value="Submit"> 
 
\t \t \t \t \t </div> 
 
\t \t \t \t \t <div id="cfright"> 
 
\t \t \t \t \t \t <input type="reset" value="Clear Fields"> 
 
\t \t \t \t \t </div> 
 
\t \t \t \t </div> 
 
\t \t \t </div> 
 
\t \t \t </form>

次のように:

<?php 
if(isset($_POST['email'])) { 

    // CHANGE THE TWO LINES BELOW 
    $email_to = "[email protected]"; 

    $email_subject = "AdamGalushaCSIS310.com Contact Form Data"; 


    function died($error) { 
     // your error code can go here 
     echo "We are very sorry, but there were error(s) found with the form you submitted. "; 
     echo "These errors appear below.<br /><br />"; 
     echo $error."<br /><br />"; 
     echo "Please go back and fix these errors.<br /><br />"; 
     die(); 
    } 

    // validation expected data exists 
    if(!isset($_POST['first_name']) || 

     !isset($_POST['last_name']) || 

     !isset($_POST['email']) || 

     !isset($_POST['phone']) || 

     !isset($_POST['availability'])) { 

     died('We are sorry, but there appears to be a problem with the form you submitted.');  

    } 

    $first_name = $_POST['first_name']; // required 
    $last_name = $_POST['last_name']; // required 
    $email_from = $_POST['email']; // required 
    $address = $_POST['address']; // not required 
    $city = $_POST['city']; // not required 
    $state = $_POST['state']; // not required 
    $phone = $_POST['phone']; // required 
    $availability = $_POST['availability']; // required 
    $reason1 = $_POST['reason1']; // not required 
    $reason2 = $_POST['reason2']; // not required 
    $reason3 = $_POST['reason2']; // not required 
    $reason_other = $_POST['reason_other']; // not required 


    $error_message = ""; 
    $email_exp = '/^[A-Za-z0-9._%-][email protected][A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; 
    if(!preg_match($email_exp,$email_from)) { 
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; 
    } 
    $string_exp = "/^[A-Za-z .'-]+$/"; 
    if(!preg_match($string_exp,$first_name)) { 
    $error_message .= 'The First Name you entered does not appear to be valid.<br />'; 
    } 
    if(!preg_match($string_exp,$last_name)) { 
    $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; 
    } 
    if(strlen($availability) < 2) { 
    $error_message .= 'The Availability you entered does not appear to be valid.<br />'; 
    } 
    if(strlen($error_message) > 0) { 
    died($error_message); 
    } 
    $email_message = "Form details below.\n\n"; 

    function clean_string($string) { 
     $bad = array("content-type","bcc:","to:","cc:","href"); 
     return str_replace($bad,"",$string); 
    } 

    $email_message .= "First Name: ".clean_string($first_name)."\n"; 
    $email_message .= "Last Name: ".clean_string($last_name)."\n"; 
    $email_message .= "Email: ".clean_string($email_from)."\n"; 
    $email_message .= "Phone Number: ".clean_string($phone)."\n"; 
    $email_message .= "Address: ".clean_string($address)."\n"; 
    $email_message .= "City: ".clean_string($city)."\n"; 
    $email_message .= "State: ".clean_string($state)."\n"; 
    $email_message .= "Best time to contact: ".clean_string($availability)."\n"; 
    $email_message .= "Contacting for: ".clean_string($reason1)."\n"; 
    $email_message .= "Contacting for: ".clean_string($reason2)."\n"; 
    $email_message .= "Contacting for: ".clean_string($reason3)."\n"; 
    $email_message .= "Contacting for: ".clean_string($reason_other)."\n"; 


// create email headers 
$headers = 'From: '.$email_from."\r\n". 
'Reply-To: '.$email_from."\r\n" . 
'X-Mailer: PHP/' . phpversion(); 
@mail($email_to, $email_subject, $email_message, $headers); 
?> 

<!-- place your own success html below --> 

Thank you for contacting us. We will be in touch with you very soon. 

<?php 
} 
die(); 
?> 

答えて

0

あり単純なエラー。

この:

<img src="images/contact.png" width="20%> 

このことが必要です。

<img src="images/contact.png" width="20%"> 
+0

すごいああ...私はそれがすべてだったのです信じることができません。あなたは命の恩人です!それはあなただよ! –

+0

しかし...送信時にサーバーからエラー403が表示される...権限エラー? –

+0

httpサーバーの設定に問題があります。 – Jandisson

関連する問題