Problema header con dreamweaver cs3 e PHP

arkom

Nuovo Utente
5 Mag 2009
4
0
0
salve, sono tre mesi che cerco la soluzione ma non ho trovato niente.
Sarei grato se qualcuno mi aiutasse a risolvere questo problema con dreawweaver e php.
Sto tentanto (in vano ahimè) di risolvere un form di login (utente e password) ma mi da un errore di header quando provo ad inviare i dati. posto qua il codice:
=====================================================
<?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>
=====================================================
 
ricorda che per poter utilizzare la funzione header() questa deve essere inserita prima di qualsiasi output html, comprese le intestazioni.
 
grazie

Grazie Eliox e Filippo per le vostre risposte siete stati cosi gentile, ma per me che sono un neofito del settore, non è cosi facile capire. Ossia ne caso specifico l' "HEADER" sta già prima di "<!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">" e di qualsiasi inzio di parte HTML. Dunque con esatezza dove dovrei spostare gli header o il codice riguardante questi?
Se potete riscrivere il mio codice indicando come devo fare ve ne sarei grato.
 
ditemi se ho capito

Allora se ho capito bene dovrei iniziare la funzione cosi:
====================================
<?php
ob_start();

echo('HTML'); // output

session_start();
?>


========================================
e poi seguire con il restante del codice cosi ?
========================================

<?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>


=================================================

Spero di avere capito bene se no qua sono un fallimento totale, comunque grazie ancora per le delucidazioni Eliox e Filippo
 

Discussioni simili