Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

194
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda