Error redirecting to another page while doing Submit

Asked

Viewed 58 times

-2

I’m new to web programming, but I can’t find the error. I have a index.php, where there are 3 inputs for research, by code, Cpf or name.

After on the same page is shown the result in the form of link by found code of the search. this link directs on resultcontrato.php, where details about this code. In this resultcontrato.php has a Ubmit where directs to the page index.php 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'];

resulscontrate.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:

erro quando clico em new busca e volta para a index.pnp

1 answer

1

Check 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 receives a temporary value

  • Good morning Felipe, not she was created after passing through the Forms.

Browser other questions tagged

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