Error of Sending Form

Asked

Viewed 71 times

1

I have a form:

          <form action="/register.php" role="form" method="post" name="novaEmpresa" >
            <input name="ref" type="hidden" value='<?php echo $ref ?>' />
            <label class="lbl">CNPJ da Empresa</label>
            <div id="document" class="form-group">
              <input type="text" name="document" class="form-control" placeholder="CNPJ da Empresa" />
              <label for="document" class="text-danger">Informe um documento válido</label>
              <i class="fa fa-2x form-control-feedback"></i>
            </div>

            <div id="DivDtaNasc" hidden>
            <label class="lbl">Data de Nascimento</label>
              <div id="dtanasc" class="form-group">
                <input type="text" name="dtanasc"  class="form-control" placeholder="CNPJ/CPF da Empresa" />
                <label for="dtanasc" class="text-danger">Informe uma data válida</label>
                <i class="fa fa-2x form-control-feedback"></i>
              </div>
            </div>

            <label class="lbl">Nome da Empresa</label>
            <div id="company" class="form-group">
              <input name="company" type="text" class="form-control" placeholder="Nome da Empresa" />
              <label for="company" class="text-danger">Informe uma nome válido (3 caracteres ou mais)</label>
              <i class="fa fa-2x form-control-feedback"></i>
            </div>
            <label class="lbl">Seu Nome</label>
            <div id="name" class="form-group">
              <input name="name" type="text"  class="form-control" placeholder="Seu Nome" />
              <label for="name" class="text-danger">Informe um nome válido (3 caracteres ou mais)</label>
              <i class="fa fa-2x form-control-feedback"></i>
            </div>
            <label class="lbl">Seu e-mail</label>
            <div id="email" class="form-group">
              <input name="email" type="email" class="form-control" placeholder="Seu e-mail"  />
              <label for="email" class="text-danger">Informe um email válido</label>
              <i class="fa fa-2x form-control-feedback"></i>
            </div>
            <button class="btn btn-danger btn-block btn-lg" role="button" id="BtnSend">Criar minha conta</button>

          </form>

And I need to send the info on this one form to the archive register.php down below:

    <?php 

  if (!$_POST) {
    header('Location: http://00.00.000.000/');
    die();
  }

  try {
    header("Access-Control-Allow-Origin: *");
    $name     = addslashes($_POST["name"]);
    $email    = addslashes($_POST["email"]);
    $refer    = addslashes($_POST["ref"]);
    $document = addslashes($_POST["document"]);
    $company  = addslashes($_POST["company"]);

//$name = str_replace('&', ' ', $name);
//$company = str_replace('&', ' ', $company);

$url = "http://piloto.minhaempresa.com.br/ws/servico.asmx/RegistraEmpresa";

$t ="{'NomeEmpresa':'$company','NomeResponsavel':'$name','CpfCnpjEmpresa':'$document','Email':'$email','IdEmpresaIndicou':'$refer'}";

$content = "InfoEmpresa={ 'bs64':'".base64_encode($t)."'}";

//echo $bs64 = "bs64=". base64_encode($content);

$curl = curl_init($url);

curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);

$response = curl_exec($curl);

$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

curl_close($curl);

   $xml = simplexml_load_string($response);
    if($xml == 'true')  {
      echo "OK";
    } else {
      echo $xml;
    }

  } catch (Exception $e) {
    echo 'Erro: ',  $e->getMessage(), "\n";  
  } 

Up to this point, I could understand everything that is happening, but when I go to the site and enter the information on form and click Add, the following error message appears:

Error: Undefined object reference for an object instance

  • Which line is showing error ?

  • Referência de objeto não definida ... this here is javascript error.

  • 1

    I really have a js doing the validation of the cnpj field, but I can’t find the error. .

  • The error shows the line of the error, displays the source code, and sees which instruction is troublesome. Your object should be null.

  • @rray , sorry for the comment, I don’t know if this is what I understood. But in the source code I couldn’t find any instructions with problem! also searched for null object and did not find.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.