2015-10-15 29 views
-2

我寫了一個註冊在PHP頁面,一切正常和值都被保存在數據庫中,但之後的值保存到數據庫中的不開放下一頁 這裏是我的碼。請檢查可能是什麼問題。獲取值到數據庫中,但歡迎頁面無法打開

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

    $st_name=$_POST['st_name']; 
    $f_name=$_POST['f_name']; 
    $email=$_POST['email']; 
    $re_email=$_POST['re_email']; 
    $pass=$_POST['pass']; 
    $re_pass=$_POST['re_pass']; 
    $phone=$_POST['phone']; 
    $mobile=$_POST['mobile']; 
    $skype=$_POST['skype']; 
    $quali=$_POST['quali']; 
    $country=$_POST['country']; 
    $city=$_POST['city']; 
    $date=$_POST['date']; 
    $g=$_POST['g']; 
    $image="back.jpg"; 
    if($email!=$re_email){ 
    echo "<script>window.open('sign_up.php?error=email_error','_self')</script>"; 
    } 
    else if($pass!=$re_pass){ 
    echo "<script>window.open('sign_up.php?error=pass_error','_self')</script>"; 

    } 
    else{ 


     $que="insert into sign_up(st_name,f_name,email,re_email,pass,re_pass,phone,mobile,skype,quali,country,city,date,gender,image) 
     values ('$st_name','$f_name','$email','$re_email','$pass','$re_pass','$phone','$mobile','$skype','$quali','$country','$city','$date','$g','$image')"; 
     if(mysql_query($que)) 
     { 
     $_SESSION['email']=$email; 
     $_SESSION['pass']=$pass; 

      header("location: index.php"); 


     } 
     else{ 
     mysql_error(); 

     } 
     } 
} 

?> 
+0

如果加上'在session_start()會發生什麼;在' Jamesking56

+0

我寫了session_start();在頂部 –

回答

0

簡單的錯字

變化

header("location: index.php");

header("Location: index.php");

+0

沒有工作,現在顯示此錯誤警告:不能更改頭信息 - 頭已經發出(輸出開始在E:\ XAMPP \ htdocs中\學校\ sign_up.php:423)在E:\ XAMPP \ htdocs中\學校\上線459 –

+0

sign_up.php加入ob_start()的開始。 – Pupil

+0

它的脫機工作,但網上沒有甚至在網上工作顯示此錯誤警告:在session_start():不能發送會話緩存限制器 - 在/ home/daremuslim已經發送了頭(輸出開始/home/daremuslim/public_html/sign_up.php:2) /public_html/sign_up.php第3行 你可以在這裏http://daremuslim.com/sign_up.php –

0

不知道這是否有差別或沒有,但header("location: index.php");需要將L上Locatio資本Ñheader("Location: index.php");

+0

檢查錯誤stll不工作 –

+0

試試這個,因爲它看起來像頭已經posted'header(「刷新:1; url = index.php「); ' – jagler

0

如果未發送的報頭那麼這意味着該條件沒有被評估爲真。當你撥打的頭因爲劇本尚未完成離開頁面之前運行 Session變量不會被保存。要在發送位置標題之前保存變量,請使用session_write_close()

1

問題是,在您調用header()函數之前,您正在輸出某些內容。在調用該函數之前,您需要確保HTML輸出中沒有任何內容(甚至不包括空格)。