Error redirecting to another page while submitting

-2

I'm new to web programming, but I can not seem to find the error. I have a index.php , where you have 3 inputs to search by code, cpf or name.

After the same page is shown the link result by search code found. this link directs in resultcontrato.php , where it details on this code. In this resultcontrato.php has a submit where it directs to the index.php page again, that's where the error described below comes in.

Index.php

<fieldset>
<legend>Pesquisa</legend>
<form name="frmbuscacontrato" method="post" action="index.php"  enctype="multipart/form-data">
    <label><span style="color: #ffffff"><strong>Empresa:</strong></span><strong>&nbsp;&nbsp;</strong>&nbsp;&nbsp;&nbsp;</label>
    <select  name="selemp">
        <option value="3">3</option>
        <option value="2">2</option>
        <option value="1">1</option>
    </select>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ffffff"><strong>Contrato:</strong></span>
<input name="inpcont" type="text" id="inpcont" placeholder="Buscar..." title="Preencha o campo com o NÚMERO do contrato."/><input id="btnBusca" type="image" src="img/lupasemfundo-22x22.png" vspace="0" hspace="0" onclick="index.php.frmbuscacontrato.submit()"/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label style="color:#FFFFFF"><strong>OU</strong></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label style="color: #ffffff"><strong>CPF/CNPJ:</strong></label>
<input name="inpcpf" type="text" id="inpcpf" placeholder="Buscar..." title="Preencha o campo SOMENTE com NÚMEROS."/><input id="btnBusca" type="image" src="img/lupasemfundo-22x22.png" vspace="0" hspace="0" onclick="index.php.frmbuscacontrato.submit()"/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label style="color:#FFFFFF"><strong>OU</strong></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label style="color: #ffffff"><strong>Nome:</strong></label>
<input name="inpnome" type="text" id="inpnome" placeholder="Buscar..." title="Preencha o campo com o NOME do contratante."/><input id="btnBusca" type="image" src="img/lupasemfundo-22x22.png" vspace="0" hspace="0" onclick="index.php.frmbuscacontrato.submit()"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</form>
</fieldset>
<!--
* Inicio busca dados do contrato
-->

<?php
session_start();
$vlremp=$_POST['selemp'];
$vlrcont=$_POST['inpcont'];
$vlrcpf=$_POST['inpcpf'];
$vlrnome=$_POST['inpnome'];
$_SESSION['selemp'] = $_POST['selemp'];
$_SESSION['inpcont'] = $_POST['inpcont'];

resulscontrato.php

<?php session_start();?><!doctype html>
<?php
# Informa qual o conjunto de carcteres será usado.
header('Content-Type: text/html; charset=utf-8');
ini_set('default_charset', 'UTF-8');
?>
<?php
    include "connexion.php";
    include "funcoes.php";
?>
<html>
<head>
<meta http-equiv="content-type"  content="text/html; charset=utf-8">
<!--<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" />-->
<title>Contratos web</title>
<style type="text/css" media="screen">
@import url("css/style.css");
</style>
<meta name="description" content="Contrato">
</head>
<body>
<?php
$vlrcont=$_GET['contpassado'];
$vlremp = $_SESSION['selemp'];
?> 
<div id="box">
<fieldset>
<legend>Pesquisa Contratro</legend>
<form name="frmnewbusca" method="post" action="index.php"  enctype="multipart/form-data" >
  <span style="color: #ffffff"><strong>&nbsp;&nbsp;&nbsp;&nbsp;Nova pesquisa&nbsp;&nbsp;</strong></span>
  <input name="inpbusca" type="hidden"  id="contpassado" value="$vlrcont" size="08" maxlength="8"/><input id="btnnewBusca" type="image" src="img/lupasemfundo-22x22.png" vspace="0" hspace="0" onclick="index.php.submit()"/>
</form>
</fieldset>

Error:

    
asked by anonymous 24.08.2016 / 03:53

1 answer

1

Verify that the variable was created before setting the variable for example.

session_start();

$vlremp=(isset($_POST['selemp'])) ? $_POST['selemp'] : '';

$_SESSION['selemp'] = (isset($_POST['selemp'])) ? $_POST['selemp'] : '';

If it was not created it gets a temporary value

    
24.08.2016 / 04:08