2014-03-31 3 views
-1

양식의 코드가 내 웹 사이트에 복사되었습니다. 제출하지 않습니다 ... 누군가가 문제를 볼 수 있습니까?PHP 양식을 제출하면 빈 페이지가 열림

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

// EDIT THE 2 LINES BELOW AS REQUIRED 
$email_to = "[email protected]"; 
$email_subject = "פנייה מהאתר"; 


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 " מלא את כל הפרטים בבקשה.<br /><br />"; 
    die(); 
} 

    // validation expected data exists 
    if(!isset($_POST['name']) || 
    !isset($_POST['email']) || 
    !isset($_POST['telephone']) || 
    !isset($_POST['comments'])) { 
    died(' אחד הפרטים חסר. מלא את כל הפרטים בבקשה');  
} 

$first_name = $_POST['first_name']; // required 
$email_from = $_POST['email']; // required 
$telephone = $_POST['telephone']; // not required 
$comments = $_POST['comments']; // 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 .= 'נא מלא פרטים נכונים.<br />'; 
} 
if(strlen($comments) < 2) { 
$error_message .= 'The Comments you entered do 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 .= "Name: ".clean_string($first_name)."\n"; 
$email_message .= "Email: ".clean_string($email_from)."\n"; 
$email_message .= "Telephone: ".clean_string($telephone)."\n"; 
$email_message .= "Comments: ".clean_string($comments)."\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); 
?> 





<!doctype html> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" dir"=rtl"> 
<meta name="keywords" content="פורום בית חכם,בית חכם, חשמל חכם, בקרת חשמל, ניהול חשמל,  חסכון בחשמל, אמצעי בקרת חשמל, כמה עולה בית חכם, מחירי חשמל חכם, מערכות בית חכם, תכנון בית חכם"> 
<link rel="stylesheet" href="style.css" type="text/css"> 
<link rel="stylesheet" href="contact_style.css" type="text/css"> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript" charset="utf-8"></script> 
<script src="js/jquery.uniform.min.js" type="text/javascript" charset="utf-8"></script> 
<script type="text/javascript" charset="utf-8"> 
$(document).ready(function(e){ 
$("input:checkbox, input:radio").uniform(); 
$('#top').css('float','none'); 
$('.content_window').css('height','auto'); 
}); 
</script> 
<title>IntraHouse - צור קשר</title> 

</head> 

<body> 
<div class="background"> 
<div class="content_window"> 
<header> 
<div class="languages"> 
     <a href="indexEnglish.html">English</a> 
     <a href="index.html">עברית</a> 
    </div> 
<div id="app_theme" style="margin-top:3px" ></div> 
    <div id="top" style="margin-top:2px" style="float:none" > 
     <nav id="topmenu"> 
      <ul> 
       <li id="home"><a href="index.html">דף הבית </a></li> 
       <li id="about"><a href="#">אודות </a></li> 
       <li id="prices"><a href="prices.html">מחירים</a></li> 
       <li id="projects"><a href="projects.html">פרוייקטים</a></li> 
       <li id="store"><a href="store.html">חנות</a></li> 
       <li id="contact_us"><a href="contact_us.html">צור קשר</a></li>    
      </ul> 
     </nav> 
    </div> 
</header> 
<div class="contact" style="margin-top:10px"> 
<article dir="rtl"> 
<h1 style="margin-top:10px"> נשמע מעניין? השאירו פרטים ונחזור אליכם</h1> 
<form> 
<ul> 
    <li> 
     <label for="name"> שם: </label> 
     <input type="text" size="40" id="name" /> 
    </li> 
    <li> 
     <label for="telephone"> טלפון: </label> 
     <input type="text" size="40" id="name" /> 
    </li> 
    <li> 
     <label for="email"> כתובת אימייל: </label> 
     <input type="email" size="40" id="email" /> 
    </li> 

    </li>  
     <li> 
     <label for="message">תוכן ההודעה:</label> 
     <textarea cols="50" rows="5" id="message"></textarea> 
    </li> 
</ul> 
<p> 
    <button type="reset" class="right"> אפס </button> 
    <button type="submit" class="action"> שלח </button> 

</p> 
</form> 
</article> 

</div> 
</div> 
</body> 
</html> 

<?php 
} 
?> 

자세히 볼 수 있듯이 HTML이 나타납니다. 모든 버튼이 작동하고 @ check 작업을 전자 메일로 보냅니다. 그러나 폼 서브 섹션은 빈 페이지를 엽니 다.

+0

함수 다이 함수 –

+0

그것은 그것은 상단에 정의되어있다되어 있지 않으며 사망했다. – Halcyon

+0

빈 페이지 란 무엇입니까? 값이없는 양식? 전자 메일이 전송됩니까? – Kryten

답변

0

form에는 method 또는 action이 없습니다. 일부 브라우저에서는 작동하지 않습니다.

변화에

<form> 

:

<form method="post" action="[the url of the page]"> 
0

형태의 기본 방법을 사용하여 폼 태그를 지정하지 않은 경우 그래서, 당신은 $_GET 대신 $_POST을 필요 GET입니다.

는 또한 액션 attibute 필요과 같이 태그가 보일 것입니다 : 당신은 또한이 서버로 전송됩니다 무엇으로, 모든 양식 필드에 name 속성을하지 추가해야 다음

<form action="" method="post"> 

id.

0

다음은 두 가지 중요한 문제입니다. HTML 요소의 ID는 고유해야하므로 여기에 동일한 ID로 두 가지 요소가 있습니다

<li> 
    <label for="name"> שם: </label> 
    <input type="text" size="40" id="name" /> 
</li> 
<li> 
    <label for="telephone"> טלפון: </label> 
    <input type="text" size="40" id="name" /> 
</li> 

이 변경이 필요하고, 각 요소가 name 속성을 필요로하거나이 나타나지 않습니다를 POST 배열 제대로 :

<li> 
    <label for="name"> שם: </label> 
    <input type="text" size="40" id="name" name="name" /> 
</li> 
<li> 
    <label for="telephone"> טלפון: </label> 
    <input type="text" size="40" id="telephone" name="telephone" /> 
</li> 

기타 - 모든 요소는 이름과 고유 한 ID가 있어야합니다. 특히, 귀하의 이메일 필드는 name="email"이 필요하므로 스크립트 시작 부분에 if(isset($_POST['email'])) 수표가 적용됩니다. 또한 폼은 POST 배열에 요소를 전달하기 위해 POST 메서드가 필요합니다. 당신은 단순히 작업을 생략 할 경우 양식은 같은 페이지에 제출 :

<form method="POST"> 
0

당신의 <form>이 같은 method="POST" 속성 이 있어야합니다

<input type="email" size="40" id="email" /> 
:

<form method="POST"> 

을 당신은 오류가

이어야합니다.

<input type="text" size="40" id="email" name="email" /> 

코드에서 $_POST['first_name']이 있으니 <input type="text" name="first_name" />이어야하며 name 속성이 필수입니다. PHP에서 입력 필드의 값을 얻기 위하여

당신은 사용할 필요가 name 속성

관련 문제