Muhammad Talal Muhammad Talal - 4 months ago 7x
PHP Question

php works but shows no content

I was working on a form and i had to use php to send the data through email. I am really new to coding. I just started working with php. My form works i even receive emails through it but the php page shows up blank. I tried using echo and error reporting but nothing shows up no html code shows up either. Its probably a newbie mistake. My php code:

$name = $_POST['fullName'];
$email_address = $_POST['email'];
$phone = $_POST['phoneNumber'];
$gender = $_POST['gender'];
$country = $_POST['country'];
$age = $_POST['age'];

$headers = "From:";
$to = '';
$email_subject = "Website Contact Form: $name";
$email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\ngender: $gender\n\ncountry: $country\n\nage: $age";

return true;

echo "thank you"


You have two options right now:

  1. Remove the return true;
  2. Move the echo "thank you"; before your return true;

You can read more about return here:

Side-note: you forgot a semi-colon (;) after your echo:

echo "thank you";