kidh0 0 Denunciar post Postado Junho 12, 2005 Daí gurizada, tranquilo???Estou com um livro (PHP - guia do programador) porque quero muito aprender PHP, só que estou tendo problemas com um código.É uma página com um formulário que post noutra página que vai mostrar esses dados.Acontece que só da erro:Notice: Undefined variable: Username in d:\litoralmania\testes\post1.phtml on line 10The user name is:Notice: Undefined variable: Password in d:\litoralmania\testes\post1.phtml on line 11The password is: os códigos são esses:Arquivo listing1.html:<!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><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head><body> <form action="post1.phtml" method="post"> Username: <input type="text" name="Username" /><br /> Password: <input type="password" name="Password" /><br /> <input type="submit" name="Submit" value="Submit" /> </form> </body></html>Arquivo post1.phtml:<!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><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head><body> <?php print ("The user name is: $Username<br>"); print ("The password is: $Password<br>"); ?> </body></html>Alguém pode me ajudar??? Compartilhar este post Link para o post Compartilhar em outros sites
Eclesiastes 2 Denunciar post Postado Junho 12, 2005 Que vacilo do livro. =)Utilize: $_POST["Username"] no lugar de $Username. ;) Isso vai depender do Register Globals... Compartilhar este post Link para o post Compartilhar em outros sites
kidh0 0 Denunciar post Postado Junho 12, 2005 Com as aspas no Username deu certo http://forum.imasters.com.br/public/style_emoticons/default/joia.gif , muito obrigado... Se importaria de me explicar o que vai depender do Regiter Globals??? (iniciante ao extremo) Que vacilo do livro. =) Utilize: $_POST["Username"] no lugar de $Username. ;) Isso vai depender do Register Globals... <{POST_SNAPBACK}> Mas nesse código, eu tentei dessa maneira como tu disseste, mas não deu certo, pq??? Notice: Undefined variable: FilterType in d:\litoralmania\testes\safedisplay.php on line 3 Notice: Undefined variable: TheText in d:\litoralmania\testes\safedisplay.php on line 6 Os arquivos são os seguintes: info.html: <!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> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Info</title> </head> <body> <form action="safedisplay.php" methop="post"> Enter some text:<br /> <textarea cols="40" rows="6" name="TheText"></textarea><br /><br /> Choose filtering method; <select name="FilterType" size="1"> <option value="0">none</option> <option value="1">strip_tags()</option> <option value="1">htmlentidies()</option> </select><br /><br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> E o safedisplay.php <?php error_reporting(255); switch ($FilterType) { case 0: //none $aDisplayText = $TheText; break; case 1: //none $aDisplayText = strip_tags($TheText); break; case 2: //none $aDisplayText = htmlentities($TheText); break; } ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Display</title> </head> <body> <?php print ($aDisplayText); ?> </body> </html> Compartilhar este post Link para o post Compartilhar em outros sites
Eclesiastes 2 Denunciar post Postado Junho 12, 2005 Traduza a página e leia: http://br.php.net/register_globals Um exemplo... Se o register global estiver ON você pode fazer: echo $nomeDoCampo; Ao invés de: echo $_POST["nomeDoCampo"]; Entre outras coisas... Leia, leia e o tempo lhe mostrará... ;) Compartilhar este post Link para o post Compartilhar em outros sites
Marcio Leandro 0 Denunciar post Postado Junho 12, 2005 com REGISTER_GLOBALS = 0FF você naum precisa expecificar o método pela qual a variável é enviada. Compartilhar este post Link para o post Compartilhar em outros sites
Eclesiastes 2 Denunciar post Postado Junho 12, 2005 Não é o contrário ? Compartilhar este post Link para o post Compartilhar em outros sites