Jump to content

Recommended Posts

Hello,

I am a PHP beginner and I  made a PHP page which inserts data into a MYSql database.

....
$InsertQuery->Action = "insert";
  $InsertQuery->Table = "klanten";
  $InsertQuery->bindColumn("Klantnummer", "s", "".strtoupper(((isset($_POST["Klantnummer"]))?$_POST["Klantnummer"]:""))  ."", "WA_DEFAULT");
  $InsertQuery->bindColumn("Naam_organisatie", "s", "".strtoupper(((isset($_POST["Naam_organisatie"]))?$_POST["Naam_organisatie"]:""))  ."", "WA_DEFAULT");
  $InsertQuery->bindColumn("Adres_organisatie", "s", "".strtoupper(((isset($_POST["Adres_organisatie"]))?$_POST["Adres_organisatie"]:""))  ."", "WA_DEFAULT");
  $InsertQuery->bindColumn("Postcode_organisatie", "s", "".strtoupper(((isset($_POST["Postcode_organisatie"]))?$_POST["Postcode_organisatie"]:""))  ."", "WA_DEFAULT");
  $InsertQuery->bindColumn("Woonplaats_organisatie", "s", "".strtoupper(((isset($_POST["Woonplaats_organisatie"]))?$_POST["Woonplaats_organisatie"]:""))  ."", "WA_DEFAULT");
  $InsertQuery->bindColumn("BTW_plichtig", "s", "".strtoupper(((isset($_POST["BTW_plichtig"]))?$_POST["BTW_plichtig"]:""))  ."", "WA_DEFAULT");
  $InsertQuery->bindColumn("Email", "s", "".strtoupper(((isset($_POST["Email"]))?$_POST["Email"]:""))  ."", "WA_DEFAULT");
...

After the insert, I want to send all the data with a mail to a recepient. But I can't find a way to code the "setForm" correctly with the inserted field "Email".

<?php
error_reporting(E_ALL);

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\src\Exception;

require 'PHPMailer\PHPMailer\src\Exception.php';
require 'PHPMailer\PHPMailer\src\PHPMailer.php';
require 'PHPMailer\PHPMailer\src\SMTP.php';
	
$mail = new PHPMailer();
$mail->IsSMTP(); 
$mail->Host = "smtp.myhosting.be"; 
$mail->SMTPAuth = true; 
$mail->Username = 'username@domain.com';
$mail->Password = 'password'; 
$mail->setFrom = $_POST('Email');                  // doesn't work
$mail->AddAddress('recipient@domain.com');
$mail->Subject = "subject";
$mail->Body = "text";   // in the body I want an overview of all the inserted data
$mail->IsHTML(true); 
if(!$mail->Send()) 
{ 
echo "Error sending: " . $mail->ErrorInfo;; 
} 
$mail->ClearAddresses();
$mail->ClearAttachments();
?>	

How can I do that?
Thank you in advance for your comments.

Link to comment
https://forums.phpfreaks.com/topic/311206-phpmailer-use-variables/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.