Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/01/2012, 06:19
Avatar de cmprte
cmprte
 
Fecha de Ingreso: diciembre-2011
Mensajes: 4
Antigüedad: 12 años, 3 meses
Puntos: 0
Exclamación Warning: Cannot modify header information - headers already sent by

hola, soy nuevo en esto y recien estoy aprendiendo todo esto sobre php mysql html etc.
Estoy creando una pagina web super especifica, y estoy empezando con crear una sistema de registro pero me presentan los siguientes errores

Al registrarse uno, queda registrado, pero me aparece este error.


You Are Registered And Can Now Login:

Warning: Cannot modify header information - headers already sent by (output started at /www/clanteam.com/c/o/m/comparte/htdocs/database.php:17) in /www/clanteam.com/c/o/m/comparte/htdocs/regcheck.php on line 84

y al ingresar se ingresa pero queda estre error:

Warning: Cannot modify header information - headers already sent by (output started at /www/clanteam.com/c/o/m/comparte/htdocs/database.php:17) in /www/clanteam.com/c/o/m/comparte/htdocs/Login.php on line 39


codigos:

database.php


<?

$con = mysql_connect('localhost','641714_comparte','27866 52a');

if (!$con)

{

die('Could not connect: ' . mysql_error());

}

mysql_select_db('comparte_clanteam_1');

?>


---------------------------
regcheck.php:


<?php

if(

isset( $_POST['user'] ) &&

isset( $_POST['pass'] )

)

{

if( strlen( $_POST['user'] ) < 4 )

{

echo "Username Must Be More Than 4 Characters.";

}

elseif( strlen( $_POST['pass'] ) < 4 )

{

echo "Passwrod Must Be More Than 4 Characters.";

}

elseif( $_POST['pass'] == $_POST['user'] )

{

echo"Username And Password Can Not Be The Same.";

}

else

{

include( 'database.php' );

$username = mysql_real_escape_string( $_POST['user'] );

$password = md5( $_POST['pass'] );

$sqlCheckForDuplicate = "SELECT username FROM user WHERE username = '". $username
."'";



if( mysql_num_rows( mysql_query( $sqlCheckForDuplicate ) ) == 0 )

{

$sqlRegUser = "INSERT INTO

user( username, password )

VALUES(

'". $username ."',

'". $password ."'

)";

if( !mysql_query( $sqlRegUser ) )

{

echo "You Could Not Register Because Of An Unexpected Error.";

}

else

{

echo "You Are Registered And Can Now Login";

$formUsername = $username;

header ('location: Login.php');

}

}

else

{

echo "The Username You Have Chosen Is Already Being Used By Another User. Please Try Another
One.";

$formUsername = $username;

}

}

}

else

{

echo "You Could Not Be Registered Because Of Missing Data.";

}

?>




---------------------------
login.php


<?php

session_start();

require_once 'database.php';

# make a variable out of the username that was posted in the index-page.

$username = $_POST['user'];

# I am not sure what this thing makes.. but it has something with safety to do.

$escaped_username = mysql_real_escape_string($username);

# make a md5 password.

$md5_password = md5($_POST['pass']);

$queryN = mysql_query("select * from user where username = '".$username."'
and password = '".$md5_password."' AND

level='1'");#This variable will check if the user is a level 1 user (Normal User)

$queryA = mysql_query("select * from user where username = '".$username."'
and password = '".$md5_password."' AND

level='9'");#This variable will check if the user is a level 9 user (Admin User)



if(mysql_num_rows($queryN) == 1)

{

$resultN = mysql_fetch_assoc($queryN);

$_SESSION['user'] = $_POST['user'];

header("location: index.php");

}


else{

echo "Wrong Username or Password";

}

?>

<form name="back" method="post" action="login.php">

<input type="submit" name="back" id="back" value="Back to Home">


-----------------------
Logout.php


<?php

session_start();#This will start the session

session_unset(); #Session_unset and Session_destroy

session_destroy();#Will remove all sessions.

header("location: index.php");#This code will sen du back to the index page

?>





---------------------

espero que me puedan decir cual es el problema y como arreglarlo xke he tratado y no se como, y realmente me e fijado en cada linea pero segun yo esta todo bien :S

gracias :)