2013-01-19 31 views
0

我的網站上有一個自動聯繫公式,它運行在我的本地主機服務器上,但如果我將文件加載到我的服務器上它不會工作。它似乎提交不起作用,它不會拋出一個錯誤消息,它只是重新加載頁面。我已經做了很多代碼審查,但到現在還沒有發現任何問題。 奇怪的事情對我來說是,代碼工作在我的本地而不是在服務器上...聯繫文件將不會工作

您可以自己在這裏測試:

http://144.76.1.46/RequestStream.php 

而且繼承人的代碼:

<?php 
$your_email ='[email protected]'; 

session_start(); 
$errors = ''; 
$name = ''; 
$visitor_email = ''; 
$user_message = ''; 

if(isset($_POST['Submit'])) 
{ 

    $name = $_POST['name']; 
    $visitor_email = $_POST['email']; 
    $user_message = $_POST['message']; 
    ///------------Do Validations------------- 
    if(empty($name)||empty($visitor_email)) 
    { 
     $errors .= "\n Name and Email are required fields. "; 
    } 
    if(IsInjected($visitor_email)) 
    { 
     $errors .= "\n Bad email value!"; 
    } 
    if(empty($_SESSION['6_letters_code']) || 
     strcmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0) 
    { 
    //Note: the captcha code is compared case insensitively. 
    //if you want case sensitive match, update the check above to 
    // strcmp() 
     $errors .= "\n The captcha code does not match!"; 
    } 

    if(empty($errors)) 
    { 
     //send the email 
     $to = $your_email; 
     $subject="New form submission"; 
     $from = $your_email; 
     $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; 

     $body = "A user $name submitted the contact form:\n". 
     "Name: $name\n". 
     "Email: $visitor_email \n". 
     "Message: \n ". 
     "$user_message\n". 
     "IP: $ip\n";  

     $headers = "From: $from \r\n"; 
     $headers .= "Reply-To: $visitor_email \r\n"; 

     mail($to, $subject, $body, $headers); 

     header('Location: thank-you.html'); 
    } 
} 

// Function to validate against any email injection attempts 
function IsInjected($str) 
{ 
    // censored 
    } 
    else 
    { 
    return false; 
    } 
} 
?> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
    <title>Contact Us</title> 
<!-- a helper script for vaidating the form--> 
<script language="JavaScript" src="censored" type="text/javascript"></script> 
</head> 

<body> 
<?php 
if(!empty($errors)){ 
echo "<p class='err'>".nl2br($errors)."</p>"; 
} 
?> 
<div id='contact_form_errorloc' class='err'></div> 
<form method="POST" name="contact_form" 
action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> 
<p> 
<label for='name'>Streamname: </label><br> 
<input type="text" name="name" value='<?php echo htmlentities($name) ?>'> 
</p> 
<p> 
<label for='email'>Your Email: (for possible further queries) </label><br> 
<input type="text" name="email" value='<?php echo htmlentities($visitor_email) ?>'> 
</p> 
<p> 
<label for='message'>Streamlink and explanation why he should be listed on Lol Streamgalleries: (preferably with links to reliable sources (such as leagepedia for example)</label> <br> 
<textarea name="message" rows=8 cols=30><?php echo htmlentities($user_message) ?></textarea> 
</p> 
<p> 
<img src="html-contact-form-captcha/captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' ><br> 
<label for='message'>Enter the code above here :</label><br> 
<input id="6_letters_code" name="6_letters_code" type="text"><br> 
<small>Can't read the image? click <a href='javascript: refreshCaptcha();'>here</a> to refresh</small> 
</p> 
<input type="submit" value="Submit" name='submit'> 
</form> 
<script language="JavaScript"> 
// Code for validating the form 
// Visit http://www.javascript-coder.com/html-form/javascript-form-validation.phtml 
// for details 
var frmvalidator = new Validator("contact_form"); 
//remove the following two lines if you like error message box popups 
frmvalidator.EnableOnPageErrorDisplaySingleBox(); 
frmvalidator.EnableMsgsTogether(); 

frmvalidator.addValidation("name","req","Please provide your name"); 
frmvalidator.addValidation("email","req","Please provide your email"); 
frmvalidator.addValidation("email","email","Please enter a valid email address"); 
</script> 
<script language='JavaScript' type='text/javascript'> 
function refreshCaptcha() 
{ 
    var img = document.images['captchaimg']; 
    img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000; 
} 
</script> 
</body> 
</html> 

編輯: 錯誤控制檯幫我一點點,有一個與JavaScript文件的引用的錯誤,現在修好了,但遺憾的是仍然不會工作

+0

你檢查瀏覽器錯誤控制檯? – DON

+0

確保您檢查了服務器上的錯誤日誌或啓用error_reporting以進行調試。 – Gordon

+0

thx錯誤控制檯幫了我一點,有一個JavaScript文件的參考錯誤,現在修復它,但可悲的是仍然不會工作 –

回答

3

你命名你的按鈕submit但檢查$_POST['Submit']

嘗試isset($_POST['submit'])

$_POST['submit'] == 'Submit' 
+0

已經嘗試過,可悲的是不會工作。 –

+0

@JakobAbfalter:不過,我會在那裏保留正確的名字。你的代碼可能有多個問題,這只是一個。 mercsen:你有一個錯字;您在數組索引後沒有關閉撇號。 – 11684

+0

@ 11684不知道你的意思; D不,謝謝,現在糾正 – mercsen