-1
<?php

    $NameParent = $_POST['NameParent'];
    $phone = $_POST['phone'];
    $email = $_POST['email'];
    $NameStudent = $_POST['NameStudent'];
    $course = $_POST['course'];
    $class = $_POST['class'];
    
    $to = "yourmail@gmail.com";
    
    $subject="New Submition";
    $text = "NameParent:" . $NameParent . "\r\n Phone:" . $phone . "\r\n Email:" . $email . "\r\n NameStudent:" . $NameStudent . "\r\n course:" . $course . "\r\n Class:" . $class;
    
    if($email!=NULL){
        mail($to, $subject, $text);
    }
?>

I already tried to convert the string to UTF-8, but it doesn't seem to help. Any help would be appreciated as I am very new to php and I am not at all fluent at it yet. This is my code:

  • 2
    You would need to build a HTML-formatted email with the correct content-type and encoding specified. Instead of trying to build an email yourself and manually setting all the headers yourself, use a library such as [PHPMailer](https://github.com/PHPMailer/PHPMailer) where enabling HTML in an email is one line of code (see example: https://github.com/PHPMailer/PHPMailer#a-simple-example). Using the old `mail()` function is a great way to make life a lot more difficult for yourself. – ADyson Aug 30 '23 at 11:43
  • 1
    If you still have issues while using PHPMailer, have a look at resources such as https://stackoverflow.com/questions/2491475/phpmailer-character-encoding-issues – ADyson Aug 30 '23 at 11:46
  • @ADyson Thank you for helping. I realised that the problem was that the form had the wrong encoding. – Teo Savchev Aug 30 '23 at 11:59

0 Answers0