Re_ problema con HEADER

  • Creatore Discussione Creatore Discussione arkom
  • Data di inizio Data di inizio

arkom

Nuovo Utente
5 Mag 2009
4
0
0
Salve dopo un ennesimo tentativo di risolvere un problema di "header" con l'aiuto di gentili utenti del foruma con la soluzione:
<?php
ob_start();

echo('HTML'); // output

session_start();
?>


non ho potuto ancora risolvere il problema per la registrazione utenti in questo codice che posto, realizzata con dreamweaver cs3:
<?php session_start();?>
<?php virtual('/Connections/conn.php'); ?>
<?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;
}
}
?>
<?php
// *** 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['Username'])) {
$loginUsername=$_POST['Username'];
$password=$_POST['Password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "/utente/login_ok.php";
$MM_redirectLoginFailed = "/utente/error_login.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_conn, $conn);

$LoginRS__query=sprintf("SELECT username, user_password FROM utenti WHERE username=%s AND user_password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

$LoginRS = mysql_query($LoginRS__query, $conn) 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;

if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!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>
<---ESCLUDO QUESTO PEZZO IN QUANTO NON IMPORTANTE --->
</div>
<div id="Internal_login_b">
<form ACTION="<?php echo $loginFormAction; ?>" id="form1" name="form1" method="POST">
<table width="330" align="center">
<tr>
<td scope="col"><span class="Stile4">
<label for="Username"><strong>Username</strong></label>
</span></td>
<td><input name="Username" type="text" id="Username" maxlength="20" /></td>
</tr>
<tr>
<td scope="col"><label for="Password"><span class="Stile3">Password</span></label></td>
<td><input name="Password" type="password" id="Password" maxlength="20" /></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="button" id="button" value="Login" />
</div></td>
</tr>
</table>
</form>
</div>
Qualcuno mi potrebbe indicare esattamente come devo riscrivere il codice per evitare l'errore sugli "header"
Grazie
 
tutta questa parte:
PHP:
<!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>
<---ESCLUDO QUESTO PEZZO IN QUANTO NON IMPORTANTE --->
</div>
<div id="Internal_login_b">
<form ACTION="<?php echo $loginFormAction; ?>" id="form1" name="form1" method="POST">
<table width="330" align="center">
<tr>
<td scope="col"><span class="Stile4">
<label for="Username"><strong>Username</strong></label>
</span></td>
<td><input name="Username" type="text" id="Username" maxlength="20" /></td>
</tr>
<tr>
<td scope="col"><label for="Password"><span class="Stile3">Password</span></label></td>
<td><input name="Password" type="password" id="Password" maxlength="20" /></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="button" id="button" value="Login" />
</div></td>
</tr>
</table>
</form>
</div>

nonè sottoposta a condizione, viene prodotta comunque in outup e genera l'errore
 
Anch'io avevo il tuo stesso problema e l'ho risolto scrivendo alla fine del php questo:

ob_end_flush();

Prova a utilizzarlo...dovrebbe funzionare!
 

Discussioni simili