Entonces, no sé como enviar datos de distintos formularios a mi mismo archivo php, debido a que si tengo 2 formularios en distintas páginas, los datos no los envió juntos, sino que llegan por separado, y este es el problema. Sé que no es una buena practica, si no hubieran aprobado dicho proyecto con esa vista, no tendría problema en hacer solo 1 formulario. Pero en fin, les dejaré el código por sí me pueden ayudar, estaría muy agradecido.
Ejemplo:
Código:
index.php
<form action="sendmail.php" method="post">
<input type="number" name="cedula" placeholder="ingrese su numero de cedula" maxlength=8>
<input type="submit" value="index2.php" placeholder="Ir a la carga de datos">
<form>
Código:
index2.php
<form action="sendmail.php" method="post">
<input type="text" name="nombre" placeholder="ingrese su nombre">
<input type="text" name="apellido" placeholder="Ingrese su apellido">
<input type="submit" value="#">
<form>
Código:
require("mailer\PHPMailer.php");
require("mailer/SMTP.php");
require("mailer/Exception.php");
$mail = new PHPMailer\PHPMailer\PHPMailer();
$nombre = $_POST['nombre'];
$apellido = $_POST['apellido'];
$cedula = $_POST['cedula'];
include("index2.php");
include("index.php");
try {
//Server settings
$mail->SMTPDebug = 0; //Enable verbose debug output
$mail->isSMTP(); //Send using SMTP
$mail->Host = 'smtp.gmail.com'; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = ''; //SMTP username
$mail->Password = ''; //SMTP pass
$mail->SMTPSecure = 'tls'; //Enable implicit TLS encryption
$mail->Port = 587; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
//Recipients
$mail->setFrom('', 'Mailer');
$mail->addAddress('', ''); //Add a recipient
//Content
$mail->isHTML(true); //Set email format to HTML
$mail->Subject = 'Nuevo ingreso';
$mail->Body = "Nueva solicitud: <br>".$nombre."Su apellido es: <br> ".$apellido. "Su cedula es <br>".
$cedula;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
header("");
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
Faltan algunos formularios, pero con eso es suficiente para explicar, solo falta la carga
de notas, necesito que este código php envíe todo, si quieren lo puedo subir a github.
Me los envía por separado, por supuesto que el archivo sendmail no lo configure por aquí, por las credenciales y eso...
Muchas gracias, y espero que me puedan ayudar, se los agradecería un montón.