silvamouro Posted May 14, 2008 at 01:57 PM Report Share #185041 Posted May 14, 2008 at 01:57 PM Imaginemos que eu quero Fazer 3 Etapas: Index.php <form id="form1" name="form1" method="post" action="passo1.php"> <table width="200" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="65">Nome:</td> <td width="135"><label> <input name="nome" type="text" id="nome" value="<?=$_SESSION['nome'];?>" /> </label></td> </tr> <tr> <td>Idade:</td> <td><input name="idade" type="text" id="idade" value="<?=$_SESSION['idade'];?>" /></td> </tr> <tr> <td></td> <td><label> <input type="submit" name="button" id="button" value="Enviar" /> </label></td> </tr> </table> </form> Passo1.php <? session_start(); $nome = $_POST['nome']; $_SESSION["nome"] = "$nome"; $idade = $_POST['idade']; $_SESSION["idade"] = "$idade"; ?> <form name="form1" method="post" action="passo2.php"> <table width="498" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="68">Profissão</td> <td width="430"><label> <input name="profissao" type="text" id="profissao" value="<?=$_SESSION['profissao'];?>"> </label></td> </tr> <tr> <td> </td> <td><label> <INPUT id="btVoltar" onClick="javascript:window.location='index.php';" type="button" value="Anterior" name="btVoltar"> <input type="submit" name="button" id="button" value="seguinte"> </label></td> </tr> </table> </form> Passo2.php <? $profissao = $_POST['$profissao']; $_SESSION["profissao"] = "$profissao"; ?> <form name="form1" method="post" action="passo2.php"> <table width="498" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="68">Morada</td> <td width="430"><label> <input name="morada" type="text" id="profissao" value="<?=$_SESSION['morada'];?>"> </label></td> </tr> <tr> <td> </td> <td><label> <INPUT id="btVoltar" onClick="javascript:window.location='passo1.php';" type="button" value="Anterior" name="btVoltar"> <input type="submit" name="button" id="button" value="seguinte"> </label></td> </tr> </table> </form> No index é um formulario contem os campos nome e idade, avanço para o passo1 onde inicio a sessa0 e grava-me os dados recebidos por post neste caso o nome e a idade, depois tenho o formulario que vou inserir a profissao e passo para o passo2.php onde ele grava o que recebeu do passo 1 que foi a profissao, mas acontece que se eu clicar no botao "anterior" ele vai voltar ao passo1.php e vai gravar nome e a idade como se fosse vazio como poço fazer para que isso não aconteça? Link to comment Share on other sites More sharing options...
cyclop Posted May 14, 2008 at 05:01 PM Report Share #185093 Posted May 14, 2008 at 05:01 PM só precisas de meter "session_start();" nos ficheiros todos 😁 "Quando eu for grande quero ser como o Celso" Link to comment Share on other sites More sharing options...
silvamouro Posted May 14, 2008 at 05:31 PM Author Report Share #185103 Posted May 14, 2008 at 05:31 PM Ele assume zero novamente! porque le os como POST só precisas de meter "session_start();" nos ficheiros todos 😉 Link to comment Share on other sites More sharing options...
psiico Posted May 14, 2008 at 07:57 PM Report Share #185132 Posted May 14, 2008 at 07:57 PM tipo: value="<?=$_SESSION['morada'];?>"> está correcto? nao seria: value="<?php echo $_SESSION['morada'];?>" Psiico // Portfolio Link to comment Share on other sites More sharing options...
djthyrax Posted May 14, 2008 at 08:09 PM Report Share #185137 Posted May 14, 2008 at 08:09 PM Está correcto sim, o <?= é um género de alias para "<?php echo ". Não peças ajuda por PM! A tua dúvida vai ter menos atenção do que se for postada na secção correcta do fórum! Link to comment Share on other sites More sharing options...
psiico Posted May 14, 2008 at 08:14 PM Report Share #185140 Posted May 14, 2008 at 08:14 PM hum ok, desculpe nao sabia 😉 Psiico // Portfolio Link to comment Share on other sites More sharing options...
cyclop Posted May 15, 2008 at 04:24 PM Report Share #185311 Posted May 15, 2008 at 04:24 PM if not isset($_session.... "Quando eu for grande quero ser como o Celso" Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now