Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

195
Visualizações
how to submit two actions(forms) by the same submit btn ? (php)

I am using code given below. I want to submit two forms values and get both values on another page listeView(ajouterAideMat.php) . By this code only values of 2nd form fetched on another page and values of first form become null. So please tell me the correct way to get the value of both forms on another page.

ps: the first form is a fetched row I want to insert it with the 2nd form witch is an insertion form , but the button submit only the 2nd form and the 1st is null as i mentioned befor


<?php  
session_start();

$con = mysqli_connect('localhost','root','' ,'bdd_globale') or die(mysqli_error());
$idAss=$_SESSION['idAss'];
$nomAss=$_SESSION['nomAss'];


$ID=isset($_SESSION['numCDD']) ? $_SESSION['numCDD'] : '';
$nom=isset($_SESSION['nom']) ? $_SESSION['nom'] : '';
$prenom=isset($_SESSION['prenom']) ? $_SESSION['prenom'] : '';
$datenaissance=isset($_SESSION['datenaissance']) ? $_SESSION['datenaissance'] : '';
$lieunaissance=isset($_SESSION['lieunaissance']) ? $_SESSION['lieunaissance'] : '';
$adress=isset($_SESSION['adresse']) ? $_SESSION['adresse'] : '';
$numTel=isset($_SESSION['numTel']) ? $_SESSION['numTel'] : '';

$date=$_POST['date'];
$idsub=$_POST['idsub'];
$liste=$_POST['liste'];
$descp=isset($_POST['descp']) ? $_POST['descp'] : '';
$quantite=$_POST['quantite']; 


$req="INSERT INTO benificieraydrstocc( idAss,nomAss,numCDD,nom,prenom,datenaissance ,lieunaissance ,adresse,numTel ,date,idsub ,typesub,description ,quantite  ) 
values('$idAss','$nomAss','$ID','$nom','$prenom','$datenaissance','$lieunaissance','$adress' ,'$numTel', '$date','$idsub','$liste','$descp','$quantite')";
$res=mysqli_query($con,$req);
     if(! $res ) { die('Could not insert data: ' .mysqli_error($con));  }
             echo '<script type="text/javascript">'; 
echo 'alert("تمت الإضافة بنجاح");'; 
echo 'window.location.href = "listeAideMat.php";';
echo '</script>';   
            mysqli_close($con);   

?> 
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Provided code isn't clear, but Yes it is possible,

Simple method would be use ajax ,prevent submit button s from submitting form and use ajax define statement /. function on click of submit button

Ref : https://www.w3schools.com/php/php_ajax_php.asp

2.another way is worst practice ever but there is click() function in jquery, by using it you perform click event from JS, use it but with this you will get some time related issue(not recommended but worth a shot) Ref : https://www.w3schools.com/jquery/event_click.asp

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda