in sostanza ho questo problema :
Potresti controllarmi il codice di questa pagina? mi da $_POST vuoto..
Allora prima cosa stampo gli utenti del database in una tabella, dopodichè quando clicco sul tasto modifica si apre una nuova action e mi prende l'id e crea i campi di testo con i relativi valori presi dal database.. poi si modificano i campi e si clicca sul pulsante modifica utente li si apre una nuova action e dovrei fare l'update nel db ma prima di quello non mi prende i valori d $_POST..
Come mai non funziona?
Codice PHP:
<?php
error_reporting(E_ALL);
session_start();
include("../config.php");
include("header.php");
if(!isset($_SESSION['admin']) || (isset($_SESSION['admin']) && $_SESSION['admin']!=1)){
header("Location: login.php");
};
if(!isset($_GET['action'])){
$content.='<form method="post">
<div class="border_wrapper">
<div class="title">Gestione degli utenti</div>
<table class="general form_container " cellspacing="0">
<thead>
<tr>
<th class="first">Utente</th>
<th class="align_center last" style="width: 200px;">Modifica</th>
</tr>
</thead>
<tbody>';
$link=mysql_connect($server,$user,$pass)or die(mysql_error());
$sel_db=mysql_select_db($db,$link)or die(mysql_error());
$query="SELECT * FROM users ORDER BY user_nome ASC";
$exec=mysql_query($query,$link)or die(mysql_error());
while($temp=mysql_fetch_array($exec)){
$content.='
<tr class="first">
<td class="first"><div style="padding-left: 0px;';
if($temp['user_stato'] == 0){
$content.=' color: red;';
};
$content.='">[b]' . $temp['user_login'] . '[/b]</div></td>
<td class="align_center last"><input onclick="location.href=\'editusers.php?action=modifica&id=' . $temp['ID'] . '\'" type="button" class="submit_button" value="Modifica"></td>
</tr>';
};
$content.='
</tbody>
</table>
</form>';
}elseif($_GET['action']=="modifica"){
$link=mysql_connect($server,$user,$pass)or die(mysql_error());
$sel_db=mysql_select_db($db,$link)or die(mysql_error());
$query="SELECT * FROM users WHERE id = " . $_GET['id'];
$exec=mysql_query($query,$link)or die(mysql_error());
$temp=mysql_fetch_array($exec);
$content.='<form method="post" action="#">
<div class="border_wrapper">
<div class="title">Modifica utente</div>
<table class="general" cellspacing="0">
<thead>
<tr>
<th class="first" colspan="6">Modifica utente</th>
</tr>
</thead>
<tbody>
<tr class="first">
<td class="alt_col_nome" width="15%">
[b]Nome login[/b]
</td>
<td class="alt_col" width="15%"><input value="' . $temp['user_login'] . '" type="text" name="login"></td>
<td class="alt_col_nome" width="15%">
[b]Password[/b]
</td>
<td class="alt_col" width="15%"><input value="' . $temp['user_pass'] . '" type="password" name="password"></td>
<td class="alt_col_nome" width="15%">
[b]Conferma password[/b]
</td>
<td class="alt_col" width="15%"><input value="' . $temp['user_pass'] . '" type="password" name="confpassword"></td>
</tr>
<tr class="alt_row">
<td class="alt_col_nome" width="15%">
[b]Nome[/b]
</td>
<td class="alt_col" width="15%">
<input value="' . $temp['user_nome'] . '" type="text" name="nome"></td>
<td class="alt_col_nome" width="15%">
[b]Cognome[/b]
</td>
<td class="alt_col" width="15%">
<input value="' . $temp['user_cognome'] . '" type="text" name="cognome"></td>
<td class="alt_col_nome" width="15%">
[b]Email Paypal[/b]
</td>
<td class="alt_col" width="15%">
<input value="' . $temp['user_email_paypal'] . '" type="text" name="paypal"></td>
</tr>
<tr class="alt_row">
<td class="alt_col_nome" width="15%">
[b]Email[/b]
</td>
<td class="alt_col" width="15%">
<input value="' . $temp['user_email'] . '" type="text" name="email"></td>
<td class="alt_col_nome" width="15%">
[b]Paese[/b]
</td>
<td class="alt_col" width="15%">
<input value="' . $temp['user_paese'] . '" type="text" name="paese"></td>
<td class="alt_col_nome" width="15%">
[b]Saldo[/b]
</td>
<td class="alt_col" width="15%">
<input value="' . $temp['user_saldo'] . '" type="text" name="saldo"></td>
</tr>
</tbody>
</table>
</div>
<div align="center">
<input class="submit_button" type="button" onclick="location.href=\'editusers.php?action=invia&id=' . $_GET['id'] . '\'" value="Modifica utente">
</div>
</form>';
}elseif($_GET['action']=="invia"){
die(print_r($_POST));
if($_POST['login'] == '' || $_POST['password'] == '' || $_POST['confpassword'] == '' || $_POST['nome'] == '' || $_POST['cognome'] == '' || $_POST['paypal'] == '' || $_POST['email'] == '' || $_POST['paese'] == '' || $_POST['saldo'] == '' || ($_POST['password'] != $_POST['confpassword'])){
$content.='<div class="error">
[i]Perfavore inserisci un valore in tutti i campi e/o correggi la password[/i]</p></div>';
}else{
$login = $_POST['login']; $passw= $_POST['password']; $nome = $_POST['nome']; $cognome = $_POST['cognome']; $paypal = $_POST['paypal']; $email = $_POST['email']; $paese = $_POST['paese']; $saldo = $_POST['saldo'];
$link=mysql_connect($server,$user,$pass)or die(mysql_error());
$sel_db=mysql_select_db($db,$link)or die(mysql_error());
//UPDATE
$query="UPDATE users WHERE id=" . $_GET['id'] . " SET user_login =\'" . $login . "\', user_password = \'" . $passw . "\', user_nome = \'" . $nome . "\', user_cognome = \'" . $cognome . "\', user_email_paypal = \'" . $paypal . "\', user_email = \'" . $email . "\', user_paese = \'" . $paese . "\', user_saldo = \'" . $saldo . "\'";
$exec=mysql_query($query,$link)or die(mysql_error());
$content.='<div class="success">
[i]Modifica dell\' utente eseguita correttamente[/i]</p></div>';
};
$content.='<script type="text/javascript">
function reindirizzamento(){
window.location = "' . $sito . '/admin/editusers.php"
}
setTimeout(\'reindirizzamento()\', 3000)
</script>';
};
?>
<!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>
<title>Modifica utente</title>
<?=$script?>
</head>
<body>
<?=$content?>
</body>
</html>