2011-06-18 60 views
-2
<?php session_start(); ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
<link href="css/css.css" rel="stylesheet" type="text/css" /> 
<style rel="stylesheet" type="text/css"> <---------------------------------8 th line 
input { 
    border-style: solid; 
    border-color: #000000; 
    border-width: 1px; 
    background-color: #ffffff; 
    } 
</style> 
<script src="js/css_browser_selector.js" type="text/javascript"></script> 

</head> 

    <body> 
<?php 

include('includes/topmenu.php');//top menu 

$yourname=''; 
$email=''; 
$email2=''; 
$password=''; 
$password2=''; 
$country=''; 


$error = array(); 

if (isset($_POST['Registerme'])) 
{ 
include('includes/config.php'); 
$yourname=$_POST['yourname']; 
$email=$_POST['email']; 
$email2=$_POST['email2']; 
$password=$_POST['password']; 
$password2=$_POST['password2']; 
$country=$_POST['country']; 

$yourname=stripslashes($yourname); 
$yourname=mysql_real_escape_string($yourname); 
$email = stripslashes($email); 
$password= stripslashes($password); 
$email = mysql_real_escape_string($email); 
$password= mysql_real_escape_string($password); 




if($yourname==''){ 

    $error[0]='<span style=color:#ff0000; >name required</span>'; 

    } 


if($email==''){ 

    $error[1]='<span style=color:#ff0000; >email required</span>'; 

    } 
if($email2==''){ 

    $error[2]='<span style=color:#ff0000; >required field</span>'; 

    } 


if($password==''){ 

    $error[3]='<span style=color:#ff0000; >password required</span>'; 

    } 


    if($password2==''){ 

    $error[4]='<span style=color:#ff0000; >required field</span>'; 

    } 


if($country==''){ 

    $error[5]='<span style=color:#ff0000; >country required</span>'; 

    } 

if ($password !== $password2) { 
    $error[3]='<span style=color:#ff0000; >passwords do not match</span>'; 

     } 

if ($email !== $email2) { 
    $error[1]='<span style=color:#ff0000; >emails do not match</span>'; 

      } 


      if(count($error) > 0) { 


      } else { 
      $password=''; 
       $id33=''; 
     $yourname=$_POST["yourname"]; 
     $email=$_POST["email"]; 
     $password=$_POST["password"]; 
     $ip=$_SERVER['REMOTE_ADDR']; 
     $country=$_POST["country"]; 

     include('includes/config.php'); 

     $result = mysql_query(" 
     INSERT INTO `users` 
     ( 
     `email`, `password`, `yourname`, `country`,`ip`) 
     VALUES ( '$email', '$password', '$yourname', '$country','$ip')") 
      or die (mysql_error()); 

     $id33= mysql_insert_id(); 

    $result3 = mysql_query("INSERT INTO `other_user_text` (`userid`) 
     VALUES ('$id33');") or die (mysql_error()); 

      $_SESSION['show']='1'; 
      mkdir("users/$id33/",0755); 
      mkdir("users/$id33/images",0755); 
      mkdir("users/$id33/thumbs",0755); <-----------------------139th line 
      mkdir("users/$id33/thumbs/small_thumbs",0755); 
      header("Location: login.php"); 
     } 
    } 
?> 

這是我的腳本,當有人在我的網站broswer中註冊時,不會指示登錄.php。顯示此錯誤警告:無法修改註冊論壇中的標題信息

警告:不能更改頭信息 - 頭已經發出(輸出開始/home/cham1992/public_html/register.php:8)在/home/cham1992/public_html/register.php線139

我嘗試了一切,但是我找不到這裏有什麼錯誤。這個頁面有什麼問題?

+0

相關的問題看起來像*可能*一個或兩個重複... – phihag

回答

1

你的代碼工作像每一個頁面之前寫一點HTML。如果您實現一個重定向,你有兩個選擇:

  1. 充分利用重定向任何HTML之前
  2. 使用腳本的頁面加載(不那麼優雅)後重定向

我會建議第1版,因此在PHP塊之後放置該HTML塊(從doctype到body),因爲你的PHP沒有任何回聲,這不會產生任何錯誤。

+0

謝謝你現在可以工作 –

1

mkdir在您的腳本中生成警告,因此目錄已經存在或您沒有創建目錄的權限。關於生成標題的警告,因爲錯誤報告試圖在報告文本之前發送標題。

我建議您使用set_error_handler進行錯誤處理。

1

要重定向到其他頁面,您通常使用:

標題( 「位置:http://www.example.com/」);

但是,在此之前不應該有任何文本或輸出發送到瀏覽器。

查看源代碼在其中警告顯示頁面和警告之前可能會有一些HTML產生應該是問題

相關問題