2015-11-13 93 views
1

當用戶填寫表單,它只是顯示黑屏PHP的聯繫表格location.href

//讓我們發送電子郵件我已創建使用HTML和PHP發送電子郵件聯絡表格。

if(!$error) { 
     //$messages="From: $email <br>"; 
     $messages.="Company Name: $name <br>"; 
     $messages.="Email: $email <br>"; 
     $messages.="Message: $message <br>"; 
     $emailto=$to; 

     $mail = mail($emailto,$subject,$messages,"from: $from <$Reply>\nReply-To: $Reply \nContent-type: text/html"); 

     if($mail) { 
      $url = 'index.php?page=process&token=101'; 
         echo "<script language=\"javascript\"> 
         location.href=\"$url\"; 
         </script>"; 
         exit; 
     } 
    } else { 

     echo '<div class="error">'.$error.'</div>'; 
    } 

} 

想如果用戶輸入的所有字段則應該把他們的index.php?頁=過程&令牌= 101

回答

0

試試這個。當您可以在PHP中重定向它們時,無法通過腳本標記回顯部分HTML頁面。

header("Location: $url"); 
0

試試這個,

echo "<script> 
    window.location = '$url'; 
</script>"; 

我建議去而不是Java腳本header()

0

在這種情況下,JavaScript的最佳做法是使用php函數進行重定向。 試試這個

header("Location: index.php?page=process&token=101");