I'm trying to make functional my contact form using variables that I put in my setting on the admin panel. The variables work perfectly since I use them in other files but I can not make them functional in the contact form I do not know if they are correctly defined or I am calling them wrong. I am waiting for your help, I am new to the page, thank you.
PD: The form works perfectly if I enter the values manually for example if in $from I put $from = ''; Because it works without problems but with the variable no.
include "inc/database.php";
$result = mysqli_query($con, "SELECT * FROM `settings` LIMIT 1") or die(mysqli_error($con));
while($row = mysqli_fetch_assoc($result)){
$contactemail = $row['contactemail'];
$adminemail = $row['adminemail'];
$secretkey = $row['secretkey'];
$website = $row['website'];
}
// require ReCaptcha class
require('recaptcha-master/src/autoload.php');
// configure
$from = ''.$row['website'].' <'.$row['contactemail'].'>';
$sendTo = '<'.$row['adminemail'].'>';
$subject = 'New message from '.$row['website'].'';
$fields = array('name' => 'Name', 'surname' => 'Lastname', 'email' => 'Email', 'message' => 'Message'); // array variable name => Text to appear in the email
$okMessage = 'Contact form successfully submitted. Thank you, I will get back to you soon!';
$errorMessage = 'There was an error while submitting the form. Please try again later';
$recaptchaSecret = ''.$row['secretkey'].'';