2 Replies - 318 Views - Last Post: 02 November 2011 - 11:44 PM Rate Topic: -----

#1 Syfer  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 190
  • Joined: 08-October 10

Header problem

Posted 02 November 2011 - 11:18 PM

First of all please disregard the format of my code if its not properly align or whatsoever
so straight to my problem

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\caps\register.php:146) in C:\xampp\htdocs\caps\register.php on line 244



last time my code works so smooth and fine but after i try it again awhile ago it went this way..

so my code is this.
<?php
include("functions.php");
include("connect.php");
?>
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type='text/Javascript' src='scw.js'></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
<script>
$(document).ready(function(){
$('#email').keyup(email_check);
});
	
function email_check(){	
var email = $('#email').val();
if(email == ""|| email.length < 15){
$('#email').css('border', '1px #000 solid');
$('#tock').hide();
}else{

jQuery.ajax({
   type: "POST",
   url: "checkemail.php",
   data: 'email='+ email,
   cache: false,
   success: function(response){
if(response == 1){
	$('#email').css('border', '1px #000 solid');	
	$('#tock').hide();
	$('#crass').fadeIn();
	}else{
	$('#email').css('border', '1px #000 solid');
	$('#crass').hide();
	$('#tock').fadeIn();
	     }

}
});
}
}
$(document).ready(function(){
$('#username').keyup(username_check);
});
	
function username_check(){	
var username = $('#username').val();
if(username == "" || username.length < 3){
$('#username').css('border', '1px #000 solid');
$('#tick').hide();
}else{

jQuery.ajax({
   type: "POST",
   url: "check.php",
   data: 'username='+ username,
   cache: false,
   success: function(response){
if(response == 1){
	$('#username').css('border', '1px #000 solid');	
	$('#tick').hide();
	$('#cross').fadeIn();
	}else{
	$('#username').css('border', '1px #000 solid');
	$('#cross').hide();
	$('#tick').fadeIn();
	     }

}
});
}
}
function blockNonNumbers(obj, e, allowDecimal, allowNegative){
	var key;
	var isCtrl = false;
	var keychar;
	var reg;
		
	if(window.event) {
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
	}
	else if(e.which) {
		key = e.which;
		isCtrl = e.ctrlKey;
	}
	
	if (isNaN(key)) return true;
	
	keychar = String.fromCharCode(key);
	
	// check for backspace or delete, or if Ctrl was pressed
	if (key == 8 || isCtrl)
	{
		return true;
	}

	reg = /\d/;
	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
	
	return isFirstN || isFirstD || reg.test(keychar);
}
function alpha(e) {
var k;
document.all ? k = e.keyCode : k = e.which;
return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 && k == _);
}
function alphaOnly(evt) 
{ 
    var charCode = (evt.which) ? evt.which : window.event.keyCode; 
 
    if (charCode <= 13) 
    { 
        return true; 
    } 
    else 
    { 
        var keyChar = String.fromCharCode(charCode); 
        var re = /[a-zA-Z- ]/ 
        return re.test(keyChar); 
    } 
}
</script>
</head>
<body>
 <div class="regs">
<form method="post" action="register.php" >
    <h1><strong>Register</strong></h1>
	<!--<p>Picture<input type="file" name="photo"/></p><br/>-->
	<p>Username: <br/><input type="text" name="username" id="username" onkeypress="return alpha(event)">
	<img id="tick" src="tick.png" width="10" height="10"/>
    <img id="cross" src="cross.png" width="10" height="10"/></p><br/>
    <p>Password:<input type="password" name="password" id="pass"></p>
	<p>First name:&nbsp <input type="text" name="first_name"onkeypress="return alphaOnly(event)"> </p>
	<p>Last name:&nbsp <input type="text" name="last_name" onkeypress="return alphaOnly(event)"> </p>
	<p>Gender:
	<input type="radio" name="gender" value="male" /> Male
    <input type="radio" name="gender" value="female" /> Female</p>
	<p>Birthdate <input onclick='scwShow(this,event);' name="birthdate" /></p>
    <p>Your Age:&nbsp &nbsp
	<?php
	 echo "<select name='age'>";
	  for ($i=11; $i <= 55; $i++){
     echo "<option value=".$i.">".$i."</option>"; }
     echo "</select>";
	?>
	</p>
	<p>Occupation:<input type="text" name="occupation" id="occu"onkeypress="return alpha(event)"></p>
	<p>Contact No.:<input type="text" name="cell_num" id="con_num" onkeypress="return blockNonNumbers(this, event, false, false);"  > </p>
	<p>Email Add:<input type="text" name="email" id="email">
    <img id="tock" src="tick.png" width="10" height="10"/>
    <img id="crass" src="cross.png" width="10" height="10"/></p>
	<p>For Minor's</p>
	<p>Parent's or Guardian's Name: <br/><input type="text" name="guardians_name" id="guard_name" onkeypress="return alpha(event)"> </p>
    <input type="submit" name="next" value="next"/></p>
</form>
  </div>
<?php
if(isset($_POST['next'])) {
$username= mysql_real_escape_string(stripslashes($_POST['username']));
$password = md5($_POST['password']);
$first_name= mysql_real_escape_string(stripslashes($_POST['first_name']));
$last_name= mysql_real_escape_string(stripslashes($_POST['last_name']));
$gender= mysql_real_escape_string(stripslashes($_POST['gender']));
$birthdate= mysql_real_escape_string(stripslashes($_POST['birthdate']));
$age= mysql_real_escape_string(stripslashes($_POST['age']));
$occupation= mysql_real_escape_string(stripslashes($_POST['occupation']));
$cell_num= mysql_real_escape_string(stripslashes($_POST['cell_num']));
$email= mysql_real_escape_string(stripslashes($_POST['email']));
$guardians_name= mysql_real_escape_string(stripslashes($_POST['guardians_name']));				
if(strlen($_POST['username'])<5 || strlen($_POST['username'])>32){
		echo 'Your username must be between 5 and 32 characters!';
	}else{
	if(empty($_POST['password']) && strlen($_POST['password'])<5){
		echo 'You need to select a password & it should be more than 6 characters!';
	}else{
	if(empty($_POST['first_name'])){
		echo 'First name is required';
		}else{
    if(empty($_POST['last_name'])){
		echo 'Last name is required';
	}else{
	if(empty($_POST['gender'])){
		echo 'Gender is required';
	}else{
	if(preg_match('/[^a-z0-9\-\_\.]+/i',$_POST['username'])){
		echo 'Your username contains invalid characters!';
	}else{
	if(!checkEmail($_POST['email'])){ 
		echo 'Your email is not valid!';
	}else

$sql = "SELECT userid FROM users_info WHERE email='".mysql_real_escape_string($_POST['email'])."'";
$query = mysql_query($sql) or die(mysql_error());
$m_count = mysql_num_rows($query);

if($m_count >= "1"){
echo 'This email has already been used.!';
}else{
$sql = "SELECT userid FROM users_info WHERE username='".mysql_real_escape_string($_POST['username'])."'";
$query = mysql_query($sql) or die(mysql_error());
$m_count = mysql_num_rows($query);
  
if($m_count >= "1"){
echo 'This username has already been used.!';
}else{
	$sql = "SELECT cell_num FROM users_info WHERE cell_num='".mysql_real_escape_string($_POST['cell_num'])."'";
                $query = mysql_query($sql) or die(mysql_error());
                $m_count = mysql_num_rows($query);
				if($m_count >= "1"){
				   echo "The Number is already exist choose another one";
				}else{
$sql = "INSERT INTO users_info SET userid = '',usergroup='member',username = '".$_POST['username']."', password= '$password', first_name = '".$_POST['first_name']."',
last_name = '".$_POST['last_name']."', gender= '$gender',birthdate= '$birthdate',age= '$age',occupation='$occupation',cell_num='$cell_num',email= '".$_POST["email"]."',
guardians_name='$guardians_name'";
$res = mysql_query($sql) or die (mysql_error());
header("location: medenthist.php?username='".$_POST['username']."'");
}}}
						}

					}
			}
	}	
	}
	}
}
}
?>

</body>
</html>



i would gladly accept any help and appreciate it ...

Is This A Good Question/Topic? 0
  • +

Replies To: Header problem

#2 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3512
  • View blog
  • Posts: 10,137
  • Joined: 08-June 10

Re: Header problem

Posted 02 November 2011 - 11:31 PM

you have lots of output before you call header(), but headers can only be sent before any output.
Was This Post Helpful? 1
  • +
  • -

#3 Syfer  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 190
  • Joined: 08-October 10

Re: Header problem

Posted 02 November 2011 - 11:44 PM

View PostDormilich, on 02 November 2011 - 11:31 PM, said:

you have lots of output before you call header(), but headers can only be sent before any output.

sorry for the late reply
already finished it , thanks anyways ^^
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1