Jump to content


Photo

Formulário Com Erro


  • Faça o login para participar
5 replies to this topic

#1 ArthurEx

ArthurEx

    Novato no fórum

  • Usuários
  • 11 posts
  • Sexo:Não informado
  • Localidade:LONDRINA - PR
  • Interesses:Webdesign.

Posted 22/01/2007, 00:56

E ae, pessoal.
É o seguinte, eu peguei um formulário que havia três campos, nome, e-mail e mensagem, ele funciona certinho.
Então eu peguei esse formulário e estou tentando alterar para colocar mais campos, só que ele não quer dar certo, pois só está chegando no meu e-mail ... um campo, que seria o ''nome'' do primeiro do formulário.
O formulário é em .htm que aciona a pagina .php, assim:

http://www.jwsoccera...trorestrito.htm

esse é o código do formulário acima em .htm

<form action="/cadastrorestrito/cadastrorestrito.php" method="post" name="form" id="form" onsubmit='return valida();'>
<input type="hidden" name="acao" value="envia" />
<p><font size="1" face="Verdana">Nome:</font>
<input name="nome" type="text" id="nome" size="27" style="font-family: Verdana; font-size: 10 px; border-style: solid; border-width: 1; padding: -2">
</p>
<p>
<input type="radio" name="radiobutton" value="radiobutton">
<font size="1" face="Verdana">Futebol</font>
<input type="radio" name="radiobutton" value="radiobutton">
<font size="1" face="Verdana">Futsal</font> </p>
<p> <font size="1" face="Verdana">Fun&ccedil;&atilde;o:</font>
<input name="email" type="text" id="email" size="26" style="font-family: Verdana; font-size: 10 px; border-style: solid; border-width: 1; padding: -2">
<font size="1" face="Verdana">ex: Jogador/T&eacute;cnico</font></p>
<p><font face="Verdana" size="1">Data de Nascimento: </font>
<input type="text" name="textfield" size="20" style="font-size: 10 px; font-family: Verdana; border-style: solid; border-width: 1; padding: -1">
<font size="1" face="Verdana">ex: ( dd/mm/aaaa)</font></p>
<p><font face="Verdana" size="1">Altura:</font>
<input type="text" name="textfield2" size="20" style="font-family: Verdana; font-size: 10 px; border-style: solid; border-width: 1; padding: -1">
</p>
<p><font face="Verdana" size="1">Peso:</font>
<input type="text" name="textfield3" size="20" style="font-size: 10 px; font-family: Verdana; border-style: solid; border-width: 1; padding: -1">
</p>
<p><font face="Verdana" size="1">Posi&ccedil;&atilde;o:</font>
<input type="text" name="textfield4" size="20" style="font-size: 10 px; font-family: Verdana; border-style: solid; border-width: 1; padding: -1">
</p>
<p><font face="Verdana" size="1">Caracter&iacute;sticas indivuduais:</font>
<textarea name="textarea" rows="2" cols="24" style="font-size: 10 px; font-family: Verdana; border-style: solid; border-width: 1; padding: -1"></textarea>
</p>
<p><font face="Verdana" size="1">Clubes onde esteve nos &uacute;ltimos anos:</font>
<input type="text" name="textfield5" size="20" style="font-size: 10 px; font-family: Verdana; border-style: solid; border-width: 1; padding: -1">
</p>
<p>
<input type="submit" name="Submit" value="Enviar" style="font-size: 10 px; font-family: Verdana; color: #FFFFFF; font-weight: bold; border-style: solid; border-width: 1; padding: -1; background-color: #008000">
<input type="submit" name="Submit2" value="Limpar" style="color: #FFFFFF; font-size: 10 px; font-family: Verdana; font-weight: bold; border-style: solid; border-width: 1; padding: -1; background-color: #008000">
</p>
<p>&nbsp;
</p>
</form>


E esse é o codigo da página que ele acina ... a pagina .php

<?
if ($_POST['acao'] == "envia") {
$nome = htmlspecialchars($_POST["nome"]);
$função = htmlspecialchars($_POST["função"]);
$datadenascimento = htmlspecialchars($_POST["datadenascimento"]);
$altura = htmlspecialchars($_POST["altura"]);
$email = $_POST["email"];
$peso = nl2br(htmlspecialchars($_POST["peso"]));

$destinatario = "arthurpr15@hotmail.com";
$assunto = "!!!ASSUNTO!!!";
$msg = "<html><head><style type=\"text/css\">"
. "body { padding:5px; margin:0; font:11px Arial, Tahoma, sans-serif; color:#333; text-align:justify; }"
. "a.link:link { color:#f60; font-weight:bold; text-decoration:none; }"
. "a.link:visited { color:#f60; font-weight:bold; text-decoration:none; }"
. "a.link:hover { text-decoration:underline; }"
. "a.link:active { text-decoration:underline; }"
. "</style><title>!!!ASSUNTO!!!</title></head><body>"
. "<strong>Nome:</strong><br /><div style=\"padding:5px;border:1px dashed #999;\">$nome</div><br />"
. "<strong>Função:</strong><br /><div style=\"padding:5px;border:1px dashed #999;\">$funcao</div><br />"
. "<strong>Data de Nascimento:</strong><br /><div style=\"padding:5px;border:1px dashed #999;\">$datadenascimento</div>"
. "<strong>Altura:</strong><br /><div style=\"padding:5px;border:1px dashed #999;\">$altura</div>"
. "<strong>Peso</strong><br /><div style=\"padding:5px;border:1px dashed #999;\">$peso</div>"
. "</body></html>";
$headers = "Content-Type: text/html; charset=iso-8859-1\n"
. "From: ".$email."\n";
$envia = mail("$destinatario", "$assunto", "$msg", "$headers");

if ($envia == "") echo "<script>alert('Formulário não enviado!');</script>";
else echo "<script>alert('Formulário enviado com sucesso!');</script>";

echo "<script>window.location='/cadastrorestrito/cadastrorestrito.htm';</script>";
}
?>


POR FAVOR!! Alguém poderia me ajudar, pois o que está errado no código??
Peço ajuda... por favor.

Agradeço desde já.

Obrigado!!!
Abraços.
: ArthurEx :
Londrina - Paraná - Brasil
[ TAT - TFA - LEC ]

#2 sk15

sk15

    Super Veterano

  • Usuários
  • 2071 posts
  • Sexo:Masculino
  • Localidade:SP - SP

Posted 22/01/2007, 01:22

Básicamente você está com erros no HTML, pois você coloco os campos e não colocou o nome correto para eles ou mesmo tem nomes repetidos nos mesmos ....

Já dentro do PHP o que falto é que você vocÊ não colocou a maioria das variaveis, e colocou-as com nomes errados com tios (~), cecedilhas (ç) e outros caracteres que não fazem eles funcionar ...

Bem seu códito HTML tava tudo entulhado e com tags erradas ... eu dei uma limpada fico assim ve se funciona ai ...

<form action="/cadastrorestrito/cadastrorestrito.php" method="post" name="form" id="form" onsubmit="return valida();">
<input type="hidden" name="acao" value="envia">

Nome: <input name="nome" type="text" size="27"><br>
E-mail: <input name="email" type="text" size="27"><br><br>

<input type="radio" name="gosto" value="futebol">Futebol<br>
<input type="radio" name="gosto" value="futsal">Futsal<br><br>

Função: <input name="funcao" type="text" size="26"> (ex: Jogador/Técnico)<br><br>

Data de Nascimento: <input type="text" name="nascimento" size="20"> (ex: dd/mm/aaaa)<br>
Altura: <input type="text" name="altura" size="20"><br>
Peso: <input type="text" name="peso" size="20"><br>
Posição: <input type="text" name="posicao" size="20"><br><br>

Características indivuduais: <textarea name="caracteristica" rows="2" cols="24"></textarea><br><br>

Clubes onde esteve nos últimos anos: <input type="text" name="ult_clubes" size="20"><br>

<input type="submit" value="Enviar">
<input type="reset" value="Limpar">
</form>

Agora o código PHP para o HTML acima:
<?php
if ($_POST["acao"] == "envia") {
 // Dados do formulário
 $nome	   = htmlspecialchars($_POST["nome"]);
 $email	  = $_POST["email"];
 $gosto	  = htmlspecialchars($_POST["gosto"]);
 $funcao	 = htmlspecialchars($_POST["funcao"]);
 $nascimento = htmlspecialchars($_POST["nascimento"]);
 $altura	 = htmlspecialchars($_POST["altura"]);
 $peso	   = htmlspecialchars($_POST["peso"]);
 $posicao	= htmlspecialchars($_POST["posicao"]);
 $caracter   = htmlspecialchars($_POST["caracteristica"]);
 $clubes	 = htmlspecialchars($_POST["ult_clubes"]);

 // Dados para o E-mail
 $destinatario = "arthurpr15@hotmail.com";
 $assunto = "!!!ASSUNTO!!!";
 $msg = "<html><head><style type=\"text/css\">"
 . "body { padding:5px; margin:0; font:11px Arial, Tahoma, sans-serif; color:#333; text-align:justify; }"
 . "a.link:link { color:#f60; font-weight:bold; text-decoration:none; }"
 . "a.link:visited { color:#f60; font-weight:bold; text-decoration:none; }"
 . "a.link:hover { text-decoration:underline; }"
 . "a.link:active { text-decoration:underline; }"
 . "</style><title>!!!ASSUNTO!!!</title></head><body>"
 . "<strong>Nome:</strong><br /><div style=\"padding:5px;border:1px dashed #999;\">$nome</div><br />"
 . "<strong>Função:</strong><br /><div style=\"padding:5px;border:1px dashed #999;\">$funcao</div><br />"
 . "<strong>Data de Nascimento:</strong><br /><div style=\"padding:5px;border:1px dashed #999;\">$nascimento</div>"
 . "<strong>Altura:</strong><br /><div style=\"padding:5px;border:1px dashed #999;\">$altura</div>"
 . "<strong>Peso:</strong><br /><div style=\"padding:5px;border:1px dashed #999;\">$peso</div>"
 . "<strong>Posição:</strong><br /><div style=\"padding:5px;border:1px dashed #999;\">$posicao</div>"
 . "<strong>Características indivuduais:</strong><br /><div style=\"padding:5px;border:1px dashed #999;\">$caracter</div>"
 . "<strong>Clubes onde esteve nos últimos ano:</strong><br /><div style=\"padding:5px;border:1px dashed #999;\">$clubes</div>"
 . "</body></html>";

 mail($destinatario, $assunto, $msg, "Content-Type: text/html; charset=iso-8859-1\nFrom: " . $email . "\n");
 echo "<script>alert('Formulário enviado com sucesso!');</script>";
} else {
 echo "<script>alert('Formulário não enviado!');</script>";
}

echo "<script>window.location='/cadastrorestrito/cadastrorestrito.htm';</script>";
?>

Edição feita por: sk15, 22/01/2007, 01:25.


#3 ArthurEx

ArthurEx

    Novato no fórum

  • Usuários
  • 11 posts
  • Sexo:Não informado
  • Localidade:LONDRINA - PR
  • Interesses:Webdesign.

Posted 23/01/2007, 23:49

Valeu, sk15!
Mas cara, é o seguinte, tá dando um erro aqui... tá dizendo que tá dando um erro na linha 35 do codigo, é onde está o ''} else {'' que erro é esse??
Olha ae... www.jwsocceracademy.com/cadastrorestrito/cadastrorestrito.htm

Agradeço desde já.
Abraço.
: ArthurEx :
Londrina - Paraná - Brasil
[ TAT - TFA - LEC ]

#4 sk15

sk15

    Super Veterano

  • Usuários
  • 2071 posts
  • Sexo:Masculino
  • Localidade:SP - SP

Posted 24/01/2007, 00:05

É estranho por que testei auqi ta normal ... a mesmos que você alterou algo no código por isso ta dando erro erro ...

Procure um "}" a mais ou faltando ... mela mensagem de erro é isso ...

#5 ArthurEx

ArthurEx

    Novato no fórum

  • Usuários
  • 11 posts
  • Sexo:Não informado
  • Localidade:LONDRINA - PR
  • Interesses:Webdesign.

Posted 24/01/2007, 00:23

MUITO OBRIGADO!!! SK15!!
Valeu cara... deu certo aqui.

Só me faz mais um favor se possível, como eu faço para funcionar aquele lugar onde o cara seleciona, se é futebol ou futsal?

MUITO OBRIGADO!!
abraço
: ArthurEx :
Londrina - Paraná - Brasil
[ TAT - TFA - LEC ]

#6 sk15

sk15

    Super Veterano

  • Usuários
  • 2071 posts
  • Sexo:Masculino
  • Localidade:SP - SP

Posted 24/01/2007, 00:55

É mesmu tinha me esquecido arrume essa parte:

...
. "<strong>Nome:</strong><br /><div style=\"padding:5px;border:1px dashed #999;\">$nome</div><br />"
. "<strong>Gosto:</strong><br /><div style=\"padding:5px;border:1px dashed #999;\">$gosto</div><br />"
. "<strong>Função:</strong><br /><div style=\"padding:5px;border:1px dashed #999;\">$funcao</div><br />"
...





1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq