Jump to content

another header problem


garydt

Recommended Posts

I can't see what I'm outputting to the screen before the headers as i'm gettinng 'cannot modify header' error.


<?php require_once('Connections/elvisdb.php'); ?>
<?php
session_start();
?>

  <?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
$user = ($_SESSION['MM_Username']);
mysql_select_db($database_elvisdb, $elvisdb);
$query_Recordset3 = "SELECT * FROM userinformation ORDER BY id DESC";
$Recordset3 = mysql_query($query_Recordset3, $elvisdb) or die(mysql_error());
$row_Recordset3 = mysql_fetch_assoc($Recordset3);
$totalRows_Recordset3 = mysql_num_rows($Recordset3);
$field = $row_Recordset3['id'];
$pass = $row_Recordset3['password'];

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE userinformation SET usernm=%s WHERE id='$field'",
                       GetSQLValueString($_POST['textfield'], "text"));

  mysql_select_db($database_elvisdb, $elvisdb);
  $Result1 = mysql_query($updateSQL, $elvisdb) or die(mysql_error());

// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['textfield'])) {
  $loginUsername=$_POST['textfield'];
  $password=$_POST['hiddenField'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "logdonuserpagenew.php";
  $MM_redirectLoginFailed = "logdonuserpagenew.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_elvisdb, $elvisdb);
  
  $LoginRS__query=sprintf("SELECT usernm, password FROM userinformation WHERE usernm=%s AND password=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
   
  $LoginRS = mysql_query($LoginRS__query, $elvisdb) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;	      

  header("Location: logdonuserpagenew.php");
  }
}
}

Link to comment
Share on other sites

You say you're not outputting anything to the screen, but two things: firstly, did you check through your included files to make sure they dont ouput anything. Second, dont forget about whitespace. The blank line at the top of the code you posted looks to me like it could be some whitespace - perhaps a newline character. You'll need to remove that too.

Link to comment
Share on other sites

tips bro:

i think the error is that the declaration of session that should always be at the top of every page

see this thing :

<?php require_once('Connections/elvisdb.php'); ?>

<?php

session_start();

?>

thats what your trying to do

i suggest try doing like this

 

<?php

session_start();

require_once('Connections/elvisdb.php');

?>

if theres is no printing action on any part cause i dont want to read your whole codes

that should work

note: no space on the top <?php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.