Php - $_post[??????]

Angelizer

Power Member
boas tenho este codigo que me cria tantas input-boxes quanto o numero de alunos obtidos na query anterior, ou seja, uma para cada um deles

Código:
<form name='nota' method='post' action='insere_notas.php'>
        <div id="tabela2">
        <div>Numero</div><div> Nota</div>
        <?php 
        while($reg=pg_fetch_array($ok)){                
            $nomeA=$reg["numero_aluno"];
            ?>
            <div><?php echo "$nomeA"?></div>
<div><input type="text" size='3' id="a<?php echo "$nomeA" ?>" name="nota" class="input-box"></input></div>
            <?php
            }

supondo que o ciclo while foi repetido 2 vezes e os valores de $nomeA=12 e 13
como faço pa saber a info que foi colocada nas box's quando carrego no botao submit??

visto que a id da minha box vai ser "a12" e a segunda "a13"
axu ke deveria ser $valor = $_POST['a$nomeA']; mas nao funciona...alguma sugestao?
 
PHP:
foreach($_POST as $k=> $v){
echo $k. ' - ' . $v . '<br>';
}

E despois tratas de cada um ou então transformas cada linha aluno num array:

<input type="text" name="aluno[0][id]">
<input type="text" name="aluno[0][nota]">

<input type="text" name="aluno[1][id]">
<input type="text" name="aluno[1][nota]">

Para aceder:

PHP:
foreach($_POST['aluno'] as $a ){
echo $a[id] . ' > ' . $a[nota];
}
 
Última edição:
Boas, aproveitando este tópico:

PHP:
if($_POST['password']==$password)

Queria adicionar o User, como é que acrescento com 'and', tive a ver exemplos mas é sempre apenas com uma condição.

Como é que faço?
 
Já agora que fizeste dump, o php não funciona dentro de plicas, pelo que em vez de:
PHP:
$valor = $_POST['a$nomeA'];
Devem utilizar
PHP:
$valor = $_POST["a${nome}A"];
 
Tenho o login assim:

PHP:
<?php
session_start();

// A password e user
$password='12345'; $user='user';

// O url para rederecciona
$url='a.php';

$autenticado=$_SESSION['autenticado'];

if($autenticado==1){
    header('Location:'.$url,TRUE,301);
    exit();
}
else {
    if($_POST['password']==$password){
        $_SESSION['autenticado']=1;
        header('Location:'.$url,TRUE,301);
    }
    elseif(isset($_POST['password']) && $_POST['password']!=$password) {
        echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/2001/REC-xhtml11-20010531/DTD/xhtml11-flat.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="content-language" content="pt" />
<meta http-equiv="imagetoolbar" content="false" />
<meta name="robots" content="noindex, nofollow" />
<style>
body {
    font-family: Georgia, Tahoma, Verdana, Arial;
    font-size: 13px;
}
.erro {
    color: #F00;
}
</style>
<title>Login</title> <body bgcolor="#B5B591" text="#336600" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" leftmargin="0" topmargin="0">
</head>
<body>
    <span class="erro">Password inválida</span><br />
    <form method="POST" action="login.php">
    <label for="password">Password:</label><input type="password" name="password" id="password" />
    <input type="submit" value="Submeter" /> 
</body>
</html>';
    }
    else {
        echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/2001/REC-xhtml11-20010531/DTD/xhtml11-flat.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="content-language" content="pt" />
<meta http-equiv="imagetoolbar" content="false" />
<meta name="robots" content="noindex, nofollow" />
<style>
body {
    font-family: Tahoma, Verdana, Arial;
    font-size: 13px;
}
</style>
<title>Login</title><body bgcolor="#B5B591" text="#336600" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" leftmargin="0" topmargin="0">
</head>
<body>
    Digite a sua senha para acessar<br />
    <form method="POST" action="login.php">
     <label for="user">User:</label><input type="user" name="user" id="user" />
    <label for="password">Password:</label><input type="password" name="password" id="password" />
    <input type="submit" value="Submeter" />
</body>
</html>';
    }
}
?>
E a outra página assm:

PHP:
<?php
session_start();

// O url para onde redireccionar 
$url='login.php';

$autenticado=$_SESSION['autenticado'];

if($autenticado==1){


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/2001/REC-xhtml11-20010531/DTD/xhtml11-flat.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="content-language" content="pt" />
<meta http-equiv="imagetoolbar" content="false" />
<meta name="robots" content="noindex, nofollow" />
<style>
body {
    background: #B5B591;
    color: #336600;
    font-family: Tahoma, Verdana, Arial;
    font-size: 13px;
}
</style>
<title>Login</title>
</head>
<body>
<p align="right"><a href="logout.php"><font color="#008000" size="4"> Terminar Sessão</font></a>    </p>
</body>
</html>
<?php
}
else {
    header('Location:'.$url,TRUE,301);
    exit();
}


?>

Não devia ser acrescentar isto? Dá erro.

PHP:
session_start();
$_SESSION['autentificado']="yes";

Include("login.php");
 
Back
Topo