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

Eliox

Utente Attivo
25 Feb 2005
4.390
3
0
ricorda che per poter utilizzare la funzione header() questa deve essere inserita prima di qualsiasi output html, comprese le intestazioni.
 

arkom

Nuovo Utente
5 Mag 2009
4
0
0
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.
 

arkom

Nuovo Utente
5 Mag 2009
4
0
0
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
Autore Titolo Forum Risposte Data
gandalf1959 [PHP] problema con l'utilizzo di Header PHP 3
gandalf1959 problema con header in area riservata PHP 4
X Problema con header() include() e i siti di hosting PHP 1
L problema con la funzione header!!! AIUTO! PHP 24
P problema con header(Location....) PHP 11
G html problema table scrollable con header fisso HTML e CSS 2
H problema tabella con header e prima colonna fissi Javascript 1
I Problema con header PHP 16
T Problema con header:"troppi reindirezzamenti" PHP 3
A Re_ problema con HEADER PHP 2
A Problema con autenticazione e header() PHP 0
Kolop [WordPress] [HTML] Problema header su mobile WordPress 4
enzonero problema immagini header WordPress 1
Emix Problema Header location... PHP 15
Dexter_90 [AIUTO!] Problema Inserimento Menu Fireworks nell'Header WordPress 11
T Forse è un problema di header..? PHP 6
K Problema variabili sessione e ...forse header PHP 6
L problema readfile e header PHP 0
I Sto progettando nuovi siti utilizzando bootstrap e devo dire funziona bene, l'unico problema e la maschera -moz- HTML e CSS 0
K Problema form update PHP 2
O problema con dvr dahua xvr5116 IP Cam e Videosorveglianza 0
S Problema nel ciclare un json Javascript 0
G Problema con Xampp Web Server 1
andrea barletta Problema con miniature comandi Photoshop 0
I problema con alice Posta Elettronica 0
K Problema Inner join PHP 1
F firefox problema http Linux e Software 0
N Problema con position absolute e overflow HTML e CSS 4
E Problema jquery Success jQuery 2
L Problema con inner join PHP 11
K [php] Problema con inner join PHP 4
E problema selezione sfumata Photoshop 2
K [PHP] Problema con variabili concatenate. PHP 1
A Problema filtro fluidifica Photoshop Photoshop 1
H Problema Bordi Scontorno Photoshop 1
O problema con query PHP 4
R Problema installazione Realtek WiFi USB rtl8821 Reti LAN e Wireless 0
I problema con 2 account Posta Elettronica 1
L problema collegamento file css con html HTML e CSS 1
Y Problema percorso file in rete PHP 1
N Problema SEO "L'URL non si trova su Google" SEO e Posizionamento 4
E Problema accesso a file con app sviluppata con MIT APP INVENTOR 2 Sviluppo app per Android 0
P Problema acquisizione clienti Webdesign e Grafica 1
F NetBeans problema creazione progetto Java Windows e Software 0
M Problema con Try Catch PHP 0
C problema seo + cerco esperto SEO e Posizionamento 11
Sergio Unia Problema con gli eventi del mouse su una data table: Javascript 2
T PROBLEMA CON SESSIONI PHP 3
A Problema, non so, di scale() o transform, oppure altro? HTML e CSS 0
T ALTRO PROBLEMA CON ARRAY PHP PHP 1

Discussioni simili