2013-10-16 2 views
-3

연락처 양식을 설정하려고합니다 : http://48hrcodes.com/contact.php 그러나 문제가 있습니다. 여기 내가 사용하고 코드입니다 :PHP 문의 양식이 작동하지 않고 오류가 발생했습니다.

<?php 

/** 
* Change the email address to your own. 
* 
* $empty_fields_message and $thankyou_message can be changed 
* if you wish. 
*/ 

// Change to your own email address 
$your_email = ""; 

// This is what is displayed in the email subject line 
// Change it if you want 
$subject = "48hrcodes contact form"; 

// This is displayed if all the fields are not filled in 
$empty_fields_message = "<p>Please go back and complete all the fields in the form.</p>"; 

// This is displayed when the email has been sent 
$thankyou_message = "<p>Thank you. Your message has been received.</p>"; 

// You do not need to edit below this line 

$name = stripslashes($_POST['txtName']); 
$email = stripslashes($_POST['txtEmail']); 
$message = stripslashes($_POST['txtMessage']); 

if (!isset($_POST['txtName'])) { 

?> 

<html lang="en"> 
<head> 
    <link href='https://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'> 
    <link href='https://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'> 
    <meta http-equiv="content-type" content="text/html; charset=utf-8"> 
    <link rel="stylesheet" href="css/style.css"> 
    <title>Free 48hr Xbox Live Gold Codes</title> 
</head> 
<body> 
     <div id="content"> 
      <div id="c1"> <center> 
      <header id="nav"> 
       <ul> 
        <li><a href="index.php">Home</a></li> 
        <li><a href="getcode.php">Get Your Code</a></li> 
        <li><a href="testimonials.php">Testimonials and Proof</a></li> 
        <li><a href="faq.php">Frequently Asked Questions</a></li> 
        <li><a href="contact.php">Contact Us</a></li> 

       </ul> 
      </header> 
       <img class="clear" src="img/grab3.png" alt="header"> 

    </center> 
    <form class="form" method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> 

     <p class="name"> 
      <input type="text" name="txtName" id="name" placeholder="John Doe" /> 
      <label for="name">Name</label> 
     </p> 

     <p class="email"> 
      <input type="text" name="txtEmail" id="email" placeholder="[email protected]" /> 
      <label for="email">Email</label> 
     </p> 

     <p class="text"> 
      <textarea name="txtMessage" placeholder="Write something to us" /></textarea> 
     </p> 

     <p class="submit"> 
      <input type="submit" value="Send" /> 
     </p> 
    </form> 
    <div id="cttxt"> 
     <h3> 
       Contact Us 
     </h3> 
     <p> 
      Simply send us message using the contact form to the left and we will get back to you within 24-48 hours. 
     </p> 
    </div> 
<center> 
       <footer> 
        © 48hrcodes.com 2013 - site by ollie rex 
       </footer> 
       </div></center> 
     </div> 
</body> 
</html> 

<?php 

} 

elseif (empty($name) || empty($email) || empty($message)) { 

    echo $empty_fields_message; 

} 

else { 

    // Stop the form being used from an external URL 
    // Get the referring URL 
    $referer = $_SERVER['HTTP_REFERER']; 
    // Get the URL of this page 
    $this_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"]; 
    // If the referring URL and the URL of this page don't match then 
    // display a message and don't send the email. 
    if ($referer != $this_url) { 
     echo "You do not have permission to use this script from another URL, nice hacking attempt moron."; 
     exit; 
    } 

    // The URLs matched so send the email 
    mail($your_email, $subject, $message, "From: $name <$email>"); 

    // Display the thankyou message 
    echo $thankyou_message; 

} 

?> 

내가 양식을 제출할 때 나는뿐만 아니라, 그 페이지의 상단에있는 오류를 얻을, 내가 얻을 이메일은 메시지 박스의 텍스트가 아닌 이름 또는 이메일을 가지고 . 나는 생각할 수있는 모든 것을 시도했지만 msg 변수를 제외하고는 아무 것도 보내지 못했습니다. 감사합니다 :)

+0

페이지 상단에 표시되는 오류 메시지는 무엇입니까? – vbrmnd

+0

링크에 액세스 할 수 있지만 여기에 게시 할 예정입니다. 알림 : 정의되지 않은 색인 : txtName in /home/nulledwa/domains/48hrcodes.com/public_html/contact.php on line 25 알림 : 정의되지 않은 색인 : txtEmail in/home/nulledwa/domains/48hrcodes.com/public_html/contact.php on line 26 알림 : 정의되지 않은 색인 : txtMessage in /home/nulledwa/domains/48hrcodes.com/public_html/contact.php on line 27 감사합니다 – ollierexx

+0

이 질문에 대한 코드를 추가하십시오 단지 pastbin이 아니라, 그것은 인정 될 것입니다. 또한이 질문에 대한 오류를 추가하십시오. 그러면 우리는 당신을 더 잘 도울 수 있습니다. – mariomario

답변

0

변화

$name = stripslashes($_POST['txtName']); 
$email = stripslashes($_POST['txtEmail']); 
$message = stripslashes($_POST['txtMessage']); 

좋아

,

$name = (isset($_POST['txtName']))?stripslashes($_POST['txtName']):""; 
$email = (isset($_POST['txtEmail']))?stripslashes($_POST['txtEmail']):""; 
$message = (isset($_POST['txtMessage']))?stripslashes($_POST['txtMessage']):""; 

가 상단에 경고를 방지하기 위해.

+0

경고가 계속 표시됩니까? 나는 똑같은 장소에 추가했다. – ollierexx

+0

@ollierexx 업데이트 답변. – vbrmnd

+0

감사합니다, 그 작품 :) 왜 다른 변수가 이메일을받지 못하는지에 대한 아이디어? – ollierexx

0

사용이

if(isset($_POST['txtName']) 
{ 
    $name = stripslashes($_POST['txtName']); 
} 
관련 문제