Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

miqueiasfer

Erro com o comando $_POST PHP

Recommended Posts

Boa Noite Pessoal,

 

É o seguinte estou desenvolvendo um site em php para um projeto na faculdade, mas estou tendo problemas com o comando $_POST. Eu tenho duas paginas

 

Pagina pag_biografia.php

 

<html>

 

<head>

 

<title>BIBLIONET</title>

</head>

 

<body bgcolor="#D8E3AE">

 

<div align="center">

 

<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#FFFFFF" width="656" id="AutoNumber1" height="357">

<tr>

<td width="656" height="150" bordercolor="#FFFFFF" style="border-bottom-style: solid; border-bottom-width: 1">

<img border="0" src="images/BannerBiblio.gif" width="656" height="150"></td>

</tr>

<tr>

<td width="86%" height="21" style="border-top-style: solid; border-top-width: 1">

<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-top-width: 0" bordercolor="#B1C95D" width="100%" id="AutoNumber2" bgcolor="#FFFFFF">

<tr>

<td width="16%" style="border-top-style: none; border-top-width: medium">

<font color="#6A8224" face="Comic Sans MS" size="2"> > Quem somos</font></td>

<td width="21%" style="border-top-style: none; border-top-width: medium">

<font color="#6A8224" face="Comic Sans MS" size="2"> > Alterar

Cadastro</font></td>

<td width="11%" style="border-top-style: none; border-top-width: medium">

<font color="#6A8224" face="Comic Sans MS" size="2"> > Obras</font></td>

<td width="15%" style="border-top-style: none; border-top-width: medium">

<font color="#6A8224" face="Comic Sans MS" size="2"> > Biografias</font></td>

<td width="23%" style="border-top-style: none; border-top-width: medium">

<font color="#6A8224" face="Comic Sans MS" size="2"> > Análises

Biográficas</font></td>

<td width="14%" style="border-top-style: none; border-top-width: medium">

<font color="#6A8224" face="Comic Sans MS" size="2"> > Sugestões</font></td>

</tr>

</table>

</td>

</tr>

<tr>

<td width="86%" height="184" bgcolor="#FFFFFF" align="center">

<form method="POST" action="pdf.php">

<!--webbot bot="SaveResults" u-file="C:\Documents and Settings\USER\Meus documentos\Priscila\Site PI_Verde\_private\form_results.csv" s-format="TEXT/CSV" s-label-fields="TRUE" -->

 

<p style="margin-top: 0; margin-bottom: 0" align="center"> </p>

<p style="margin-top: 0; margin-bottom: 0" align="center"> </p>

<p style="margin-top: 0; margin-bottom: 0" align="center"> </p>

<p style="margin-top: 0; margin-bottom: 0" align="center"> </p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

<font face="Comic Sans MS" color="#55671D" style="font-size: 14pt">BIOGRAFIAS</font></p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

 </p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

 </p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

 </p>

<table border="0" cellpadding="0" style="border-collapse: collapse" width="60%" id="table2">

<tr>

<td align="center">

<font color="#55671D" face="Comic Sans MS" style="font-size: 10pt">

Encontre aqui tudo sobre a vida e obras do autor desejado, basta

escolher abaixo o nome do autor .</font></td>

</tr>

</table>

<p style="margin-top: 0; margin-bottom: 0" align="center">

 </p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

 </p>

<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="60%" id="table1" bordercolor="#B1C95D">

<tr>

<td> <p align="center">

 

<?php

 

include ("conectar.php");

 

$result=mysql_query("select NmAutor from tbcautor") or die("erro ao conectar");

 

if (mysql_num_rows($result)>0 ){

 

echo "<select name = 'Biografia'>";

echo" <option selected> Autor </option>";

 

while($linha = mysql_fetch_array($result)){

 

echo" <option value = $linha[NmAutor]>$linha[NmAutor]</option>";

 

}

echo "</select>";

}

?>

 

</p>

<p align="center">

<input type="submit" value="Enviar"></td>

</tr>

</table></form>

<p style="margin-top: 0; margin-bottom: 0" align="left"> </p>

<p style="margin-top: 0; margin-bottom: 0" align="left"> </p>

<p style="margin-top: 0; margin-bottom: 0" align="left"> </p>

<p style="margin-top: 0; margin-bottom: 0" align="center">

 </p>

<p style="margin-top: 0; margin-bottom: 0"> </p>

<p style="margin-top: 0; margin-bottom: 0"> </p>

<p style="margin-top: 0; margin-bottom: 0"> </p>

</td>

</tr>

</table>

 

</div>

</body>

 

</html>

 

pagina pdf.php

 

<?php

 

$autor="$_POST[biografia]";

echo $autor;

include ("conectar.php");

 

$select= "select * from tbcautor where NmAutor= '$autor'";

 

$result=mysql_query($select) or die("erro ao conectar");

 

if (mysql_num_rows($result)>0 ){

 

 

/*while($linha = mysql_fetch_array($result)){

header("Location: $linha[biografia]");

} */

}

?>

 

Bom O Select esta funcionando diretinho me exibindo todos os autores que tem na tabela,mas meu problema é o seguinte quando eu clico em enviar ele dá um submit e chama a pagina pdf.php e nesta pagina como podem ver estou recebendo o campo selecionado la no select da pagina pag_biografia.php.So que ai q ta o erro eu seleciono la um autor que tem um nome composto(ex:Machado de Assis),quando peço pra escrever com com echo só ta escrevendo Machado.

 

Alguem sabe o q está acontecendo? Me ajuda por favor.

Compartilhar este post


Link para o post
Compartilhar em outros sites

isto aki esta errado...

"$_POST[biografia]";

 

o certo eh

$_POST['Biografia'];

 

os includes sempre devem ser feitos no inicio da pagina e nao no meio

 

 

e outra coisa, isto esta me parecendo um sistema de busca...sistema de busca você usa $_GET e nao $_POST...aki no imasters tem uma materia d como fazer um sistema de busca...

Compartilhar este post


Link para o post
Compartilhar em outros sites

isto aki esta errado...

"$_POST[biografia]";

 

o certo eh

$_POST['Biografia'];

 

os includes sempre devem ser feitos no inicio da pagina e nao no meio

 

 

e outra coisa, isto esta me parecendo um sistema de busca...sistema de busca você usa $_GET e nao $_POST...aki no imasters tem uma materia d como fazer um sistema de busca...

 

ja tentei colocar aspas simples da forma q você disse mas nao funcionou,quando você fala que tem q usar $GET eu teria q colocar no method do formulario GET?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Se quiser mudar para o metodo GET, é só trocar no form de POST para GET, para pegar as variáveis é só colocar $_GET['var'];

 

Se quiser mudar para o metodo GET, é só trocar no form de POST para GET, para pegar as variáveis é só colocar $_GET['var'];

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.