I'm working with a contact form. The PHP code successfully delivers the form data but when I submit the form I get a log display on a new page (the form.php page), and the response message is printed at the bottom of the log and doesn't alert. Also, I would like the form page to simply reload and not redirect to the .php page. This is my first time using php so any help would be greatly appreciated. See attached image, and php below:
<form id="form-id" class="form-class" name="Form" method="post" action="form.php" onsubmit="return">
<?php
$name = $_POST['name'];
$role = $_POST['role'];
$company = $_POST['company'];
$country = $_POST['country'];
$email = $_POST['email'];
$message = $_POST['message'];
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = '';
$mail->Port = 'num';
$mail->SMTPAuth = true;
$mail->Username = 'username';
$mail->Password = 'password';
$mail->setFrom('email');
$mail->addReplyTo('email');
$mail->addAddress('email', 'Name');
$mail->Subject = 'New Message: '.$organisation;
$mail->Body =
'Name: '.$name."\r\n".
'Role: '.$role."\r\n".
'Company: '.$company."\r\n".
'Country: '.$Country."\r\n".
'Email: '.$email."\r\n".
'Message: '.$message.
if ($mail->send()) {
echo ("Thank you " .$name. ". Message sent.");
}
?>
<div id="center_button"><button onclick="location.href='team&contact#contactus'">Return</button></div>