Form Submit Error

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>

I need to send the info of this form to the file register.php 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";  
  } 

At this point, I have been able to understand everything that is happening, but when I go to the site and enter the information in form and click Add, the following error message appears:

  

Error: Object reference not set to an instance of an object

    
asked by anonymous 14.12.2015 / 19:33

0 answers