Fill Camps?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
madness
Forum Newbie
Posts: 9
Joined: Tue Jan 18, 2011 1:54 pm

Fill Camps?

Post by madness »

hi guys, can someone help me, i have a send email form, but haves a problem, when i fill the camps it says me the form it wasnt fill :\
Here is the first part of the script code:

Code: Select all

<?php

        $nome=$_POST["nome"];       
        $entidade=$_POST["empresa"];
        $telefone=$_POST["telefone"];
        $email=$_POST["email"];
        $comentarios=$_POST["comentarios"];
       

?>

<div class="txt_int_empresa">

<h1><?php echo TEXTINFORMACOESHO1 ?></h1>
<p class="texto3"><?php echo TEXTINFORMACOES11 ?></p>



<form action="?p=pedido_informacoes" method="post" name="form_contactos" id="contactos" />

<?php
        if($dados)
        {echo "Por favor preencha os campos em falta.";}
?>
<p class="texto3" style="width:230px;"><?php echo TEXTINFORMACOESO1 ?><br />
<input name="nome" type="text"  id="nome" style="width:220px;margin-top:5px;" tabindex="1" size="220" />
 <?php if($dados && $nome=="");?></p>

<p  class="texto3" style="width:230px;"><?php echo TEXTINFORMACOESO2 ?><span class="texto3" style="width:230px;">
  <input name="entidade" type="text"  id="entidade" style="width:210px; float:left;margin-top:5px;" tabindex="2" size="210" />
</span>
  <?php if($dados && $empresa=="");?>   
</p>


<p class="texto3" style="width:230px;margin-top:15px;"><?php echo TEXTINFORMACOESO5 ?><br />
<input name="telefone" type="text"  id="telefone" style="width:210px;margin-top:5px; " tabindex="7" />
<?php if($dados && $telefone=="");?>   
</p>


      <p class="texto3" style="width:230px;margin-top:15px;"><?php echo TEXTINFORMACOESO6 ?><input name="email" type="text"  id="email" style="width:220px; margin-top:5px; float:left;" tabindex="8" />
      <?php if($dados && $email=="");?>
      </p>


  <p class="texto3" style="width:450px;"><?php echo TEXTINFORMACOES10 ?><br />
 <textarea name="comentarios" rows="5"  id="comentarios" style="width:450px;font-family:Arial, Helvetica, sans-serif;font-size:12px;margin-top:5px;" cols="1" tabindex="9"></textarea>
 <?php if($dados && $comentarios=="");?>
 </p>
     
 
 <p class="texto3" style="width:100px; margin-top:14px;"> <img src="captcha/code.php" name="img_codigo" width="100" height="17" border="0" id="img_codigo" style="border:1px solid #abadb3; float:left;" ></p>
 <a href="javascript:void(0);" onclick="actualiza_captcha();"><img src="images/refresh.png" alt="actualizar" title="actualizar" width="16" height="16" border="0" alt="código"style="float:left;margin-left:13px;margin-top:18px;" ></a>
 <p style="width:90px; margin-top:16px; padding-left:11px;"><input name="codigo" type="text" class="texto2" id="codigo" style="width:80px; float:left;" tabindex="10" maxlength="5" />

 </p>
 <p style="width:70px;float:left; margin-top:14px;padding-left:11px;"> <img src="images/limpar.jpg" alt="LIMPAR" border="0" style="cursor:pointer; width:70px; height:19px ;float:left;" title="LIMPAR" onClick="javascript:form_contactos.reset();">

 <p class="texto3" style="width:90px; margin-top:16px; padding-left:69px;"><input name="enviar" type="image" onClick="return Form_Validator(form_contactos);" src="images/enviar.jpg" alt="ENVIAR" title="ENVIAR" style="height:19px; width:70px; border:none;" /></p>
 </form>   


</div>
Second script thats checks (pedido_informacoes.php):

Code: Select all

<?php

        $nome=$_POST["nome"];       
        $entidade=$_POST["empresa"];       
        $telefone=$_POST["telefone"];
        $email=$_POST["email"];
        $comentarios=$_POST["comentarios"];



if (($nome != null) && ($entidade != null) && ($telefone != null) && ($email != null) && ($comentarios != null))
{
       
        include "final_informacoes.php";
}
else
{
        $dados=true;
        include "informacoes.php";
}
?>
And last part that makes the action (final_informacoes.php):

Code: Select all

<?php
        $nome=$_POST["nome"];       
        $entidade=$_POST["empresa"];
        $telefone=$_POST["telefone"];
        $email=$_POST["email"];
        $comentarios=$_POST["comentarios"];

?>

<div class="txt_int_empresa">

<h1><?php echo TEXTINFORMACOESHO1 ?></h1>
<p class="texto3"><?php
               
$headers = "From: $email" . "\r\n" .
                 "Content-type: text/plain; charset=utf-8" . "\r\n" .
                 "X-Mailer: PHP/" . phpversion();
$to = "meumail@hotmail.com";
$subject = "Pedido de orçamento - meusite";
$body = "nome: $nome,

empresa: $empresa,

telefone: $telefone,
 
email: $email,

mensagem: $comentarios";
               
if (mail( $to , $subject , $body, $headers )) {
                  echo("$nome, o seu pedido foi enviado com sucesso.<br />
                  Em breve entraremos em contacto consigo.<br />
                  Obrigado.");
                 } else {
                  echo("$nome, ocorreu um erro no envio do seu pedido.<br />
                            Por favor volte a tentar.<br />
                            Obrigado.");
                 }

                 ?></p>
                 </div>
When i fill it, it only says : "Por favor preencha os campos em falta."

Hope for some help
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Fill Camps?

Post by califdon »

I'm sorry, but you haven't shown us the code that would allow us to understand the error. That error is sent because, at the beginning of your first code example, it says,

Code: Select all

if($dados)
        {echo "Por favor preencha os campos em falta.";}
so if $dados is true, then that message will be displayed. But you haven't shown us any code that determines what value $dados will have.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Fill Camps?

Post by Jonah Bron »

Au contraire, mon frère!

This is the code of interest (in the second script):

Code: Select all

        $dados=true;
        include "informacoes.php";
Evidently the first script is called "informacoes.php".

@madness, you should change this (informacoes.php):

Code: Select all

        $nome=$_POST["nome"];      
        $entidade=$_POST["empresa"];      
        $telefone=$_POST["telefone"];
        $email=$_POST["email"];
        $comentarios=$_POST["comentarios"];

if (($nome != null) && ($entidade != null) && ($telefone != null) && ($email != null) && ($comentarios != null))
To this:

Code: Select all

        $nome = isset($_POST['nome']) ? $_POST['nome'] : null;      
        $entidade = isset($_POST['empresa']) ? $_POST['empresa'] : null;      
        $telefone = isset($_POST['telefone']) ? $_POST['telefone'] : null;
        $email = isset($_POST['email']) ? $_POST['email'] : null;
        $comentarios = isset($_POST['comentarios']) ? $_POST['comentarios'] : null;

if (!empty($nome) && !empty($entidade) && !empty($telefone) && !empty($email) && !empty($comentarios))
http://php.net/empty
http://php.net/operators.comparison (ternary operator)
Post Reply