Problem With PHP Script

xevell

Member
Messages
39
Reaction score
0
Points
6
Hello Guys.

I am having problems creating a script in php, this is a script which holds many functions and it is called from another page.

The problem is that depending on what the function page returns the process page will redirect your browser to page. But when it trys to redirect it says that the header is already sent, meaning that somehow the scritp is outputting something.

I went through the scritp function and I am seeing that there is not out put in the code but when it is running and you go to right click view source you can notice that there is a tab space in the source and I dont see anywhere this out put.

Here is the script.

Code:
<?php
//Function Pge.

//MySQL server information.
$MySQLInfo  = array (
"Server" => "l",
"DBName" => "",
"Username" => "",
"Password" => ""
);

$CoreSettings = array  (
"TimeZone" => "America/New_York"
);

$UserSettings = array  (
"MaxPunches" => 2,
"UserLength" => 30,
"PwdLength" => 7
);

function safe($value){ 
// Stripslashes 
if (get_magic_quotes_gpc()) { 
$value = stripslashes($value); 
}
// Quote if not integer 
if (!is_numeric($value)) { 
$value = mysql_escape_string($value); 
}
return $value; 
}

function sql($query){
mysql_connect("","","");
mysql_select_db("");
$result = mysql_query($query);
mysql_close();
return $result;
}

function encryption($password,$seed){
$result = md5($password).md5($seed);
$encrypted = md5($result);
return $encrypted;
}

function authentication($username,$password){
$result = sql("SELECT Passwd FROM SCAccounts WHERE UserName='".$username."'");
if(mysql_num_rows($result) < 1){
return 1; ##If user does not exist 
}else{
$row = mysql_fetch_array($result);
if($row['Passwd'] == $password){
return 2; ##If user and password matches
}else{
return 3; //If username does not match with password.
}
}
}

function checkstatus($username){
$result = sql("SELECT ID,UserName FROM SCTimeBook WHERE UserName ='".$username."' ORDER BY ID DESC LIMIT 1"); //DESC Means descending in MySQL.
if(mysql_num_rows($result) == 0){
return 0;
}

$row = mysql_fetch_array($result);
$TimeStampIn = $row['TimeStampIn'];
$TimeStampOut = $row['TimeStampOut'];

if($TimeStampIn == NULL){
return 0;
}else{
return 1;
}
}

function gettotalpunches($username){
$result = sql("SELECT TimeStampOut FROM SCTimeBook WHERE UserName ='".$username."' AND GET_FORMAT(FROM_UNIXTIME(TimeStampOut),'ISO') = CURDATE()  ");
return mysql_num_rows($result);
}

 function signin($username){
  if(gettotalpunches($username) <= $UserSettigns["MaxPunches"]){
   sql("INSERT INTO SCTimeBook(UserName, TimeStampIn) VALUES('".$username."',".time().")");
   return header('Location: index.php?Msg=SignInOk');
  }else{
   return header('Location: index.php?Msg=MaxPunchesExceed');
  }
 }
?>


http://xevic.net/SignCard/Scripts/functions.php
if you right click view source you will notify a blank tab space.

I realize because when u fill the two textfield on http://xevic.net/SignCard/
it goes to http://xevic.net/SignCard/Scripts/pr...Action=RegForm

and when it tries to modify the header it says that its already sent because of the blank tab space.
And sometimes all of a sudden appears the html tags, but the script itself does not have anything html on it.

Thanks in advance.
 
Last edited:

TechAsh

Retired
Messages
5,853
Reaction score
7
Points
38
There is a new line before the <?php in the script you posted.
 
Top