Ir para conteúdo
Fórum Script Brasil
  • 0

Passagem De Um Valor De Um Campo Input Por Link


louvair

Pergunta

Tenho um formulario com matricula, nome, endereço e cpf, onde tenho um submit dele para inclusão no meu banco de dados através de uma rotina de inclusão.

E também gostaria de utilizar este formulario para fazer alteração de registro, informando o número da matricula, só que para isto eu gostaria de colocar uma palavra "Pesquisar" ao lado do campo, com link para rotina alteracao.php, onde passaria o valor do campo da matricula como parâmetro.

Só que não consigo fazer isto. Abaixo está o código que estou tentando implementar, desculpe pela lógica e forma de desenvolvimento, estou começando a desenvolver a pouco tempo.

Att.

Louvair

------------------------------------------------------inclusao.php---------------------------------------------

<?php

ob_start();

include( "../conexao.php" );

include( "../admin/verifica_login.php" );

error_reporting(0);

if (isset($_GET['acao'])){ $acao = $_GET['acao']; }else{ $acao = 'entrar'; }

if (isset($_GET['info'])){ $info = $_GET['info']; }else{ $info = '0'; }

if($acao == 'incluir'){

$est_matricula = $_REQUEST["estMatricula"];

$est_nome = $_REQUEST["estNome"];

$est_sexo = $_REQUEST["estSexo"];

$est_dataNasc = $_REQUEST["estDataNasc"];

$est_natural = $_REQUEST["estNatural"];

$est_nacional = $_REQUEST["estNacional"];

$est_estadoCivil = $_REQUEST["estEstadoCivil"];

$est_pai = $_REQUEST["estPai"];

$est_mae = $_REQUEST["estMae"];

$sql = mysql_query("INSERT INTO estagiario (estMatricula,estNome,estSexo,estDataNasc,estNatural,estNacional,estEstadoCivil,estPai,estMae) VALUES('$est_matricula','$est_nome','$est_sexo','$est_dataNasc','$est_natural','$est_nacional','$est_estadoCivil','$est_pai','$est_mae')") or die("Erro no SQL: ".mysql_error());

header( "location:cadastro_adm.php?info=1" );

exit;

}

?>

<div style="position:absolute; width: 593px;">

<form id="form_cadastro" name="form_cadastro" method="post" action="cadastro_inclusao.php?acao=incluir">

<label for="estMatricula">Matricula</label>

<input name="estMatricula" type="text" id="estMatricula" size="8" maxlength="8" value="0" /><a href="alteracao.php?id=estMatricula" id="pesqMatricula" class="botaoPesquisar" style="height:15px; margin: 6px 0px 0px 0px; text-align:center; width:60px; left:200px;">Pesquisar</a><br />

<label for="estNome">Nome</label>

<input name="estNome" type="text" id="estNome" size="40" maxlength="40" /><br />

<label for="estSexo">Sexo</label>

<div class="margem">

<input name="estSexo" type="radio" value="Masculino" /><a class="texto">&nbsp;Masculino</a>

<input name="estSexo" type="radio" value="Feminino" /><a class="texto">&nbsp;Feminino</a>

</div>

<label for="estDataNasc">Data de nascimento</label>

<input name="estDataNasc" type="text" id="estDataNasc" size="10" maxlength="10" /><br />

<label for="estNatural">Naturalidade</label>

<input name="estNatural" type="text" id="estNatural" size="25" maxlength="25" /><br />

<label for="estNacional">Nacionalidade</label>

<input name="estNacional" type="text" id="estNacional" size="25" maxlength="25" /><br />

<label for="estEstadoCivil">Estado Civil</label>

<input name="estEstadoCivil" type="text" id="estEstadoCivil" size="15" maxlength="15" /><br />

<label for="estPai">Nome do Pai</label>

<input name="estPai" type="text" id="estPai" size="40" maxlength="40" /><br />

<label for="estMae">Nome da m&atilde;e</label>

<input name="estMae" type="text" id="estMae" size="40" maxlength="40" />

</form>

<div>

<input class="botaoAlteracao" type="submit" name="alterar" id="alterar" value="Confirmar Alteração" />

<input class="botaoInclusao" type="submit" name="incluir" id="incluir" value="Confirmar Inclusão" />

<input class="botaoExclusao" type="submit" name="excluir" id="excluir" value="Confirmar Exclusão" />

</div>

</div>

</body>

Link para o comentário
Compartilhar em outros sites

5 respostass a esta questão

Posts Recomendados

  • 0

Bom vamos o que interessa :P :

            <?
include( "../conexao.php" );
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM estagiario WHERE id='$id'");
while($x = mysql_fetch_array($sql)){ 
echo'
<form name="form1" method="post" action="alterar.php?id='.$x[id].'">
<label for="estMatricula">Matricula</label>
<input name="estMatricula" type="text" id="estMatricula" value="'.$x[estMatricula].'" size="8" maxlength="8" value="0" /><a href="alteracao.php?id=estMatricula" id="pesqMatricula" class="botaoPesquisar" style="height:15px; margin: 6px 0px 0px 0px; text-align:center; width:60px; left:200px;">Pesquisar</a><br />

<label for="estNome">Nome</label>
<input name="estNome" type="text" id="estNome" size="40" value="'.$x[estNome].'" maxlength="40" /><br />

<label for="estSexo">Sexo</label>
<div class="margem">
<input name="estSexo" type="radio" value="Masculino" /><a class="texto">&nbsp;Masculino</a>
<input name="estSexo" type="radio" value="Feminino" /><a class="texto">&nbsp;Feminino</a>
</div>

<label for="estDataNasc">Data de nascimento</label>
<input name="estDataNasc" type="text" id="estDataNasc" size="10" value="'.$x[estDataNasc].'" maxlength="10" /><br />

<label for="estNatural">Naturalidade</label>
<input name="estNatural" type="text" id="estNatural" size="25" value="'.$x[estNatural].'" maxlength="25" /><br />

<label for="estNacional">Nacionalidade</label>
<input name="estNacional" type="text" id="estNacional" size="25" value="'.$x[estNacional].'" maxlength="25" /><br />

<label for="estEstadoCivil">Estado Civil</label>
<input name="estEstadoCivil" type="text" id="estEstadoCivil" size="15" value="'.$x[estEstadoCivil].'" maxlength="15" /><br />

<label for="estPai">Nome do Pai</label>
<input name="estPai" type="text" id="estPai" size="40" value="'.$x[estPai].'" maxlength="40" /><br />

<label for="estMae">Nome da m&atilde;e</label>
<input name="estMae" type="text" id="estMae" size="40" value="'.$x[estMae].'" maxlength="40" />
</form>

<div>
<input class="botaoAlteracao" type="submit" name="alterar" id="alterar" value="Confirmar Alteração" />
<input class="botaoInclusao" type="submit" name="incluir" id="incluir" value="Confirmar Inclusão" />
<input class="botaoExclusao" type="submit" name="excluir" id="excluir" value="Confirmar Exclusão" />
</div>
</div>';
} 
?>
Vamos chamar essa parte ai de cima como editar.php Agora vamos fazer a pagina alterar.php:
<?
include( "../conexao.php" );
$id = $_GET['id']; //peguei o id passado pela url no arquivo editar.php
$est_matricula = $_POST["estMatricula"];
$est_nome = $_POST["estNome"];
$est_sexo = $_POST["estSexo"];
$est_dataNasc = $_POST["estDataNasc"];
$est_natural = $_POST["estNatural"];
$est_nacional = $_POST["estNacional"];
$est_estadoCivil = $_POST["estEstadoCivil"];
$est_pai = $_POST["estPai"];
$est_mae = $_POST["estMae"];

$sql = mysql_query("UPDATE estagiario SET est_matricula='$est_matricula', est_nome='$est_nome', est_sexo='$est_sexo', est_dataNasc='$est_dataNasc', est_natural='$est_natural', est_nacional='$est_nacional', est_estadoCivil='$est_estadoCivil', est_pai='$est_pai', est_mae='$est_mae' WHERE id='$id';"); 
  echo "Seu cadastro foi alterado com sucesso!
         ";
}else{
   echo "Seu cadastro não pode ser alterado!";
             
}
?>

Espero que te ajude

[]'s

;)

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,9k
×
×
  • Criar Novo...