Tell me please. Has never worked with php before. I wrote my first file handler of the form, but with errors, I do not understand where ((

Here is the form

<form action="./post.php" method="POST"> <div class="sbtn col-md-12 text-center"> <input class="name form-input" type="text" placeholder="NAME" name="name"> <input class="email form-input" type="email" placeholder="EMAIL" name="email"> <input class="email form-input" type="phone" placeholder="PHONE" name="phone"> <input class="message form-input" type="text" placeholder="MASSAGE" name="message"> <input type="hidden" name="uri" value="'<php echo $_SERVER['REQUEST_URI']; ?>'"> <input type="hidden" name="site" value="'<php echo $_SERVER['SERVER_NAME']; ?>'"> <input class="submit-btn" type="submit" value="SEND"> </div> </form> 

Here is the .php file

 <?PHP //-------------------// $adminemail="ksu_dp@ua.fm"; $sender="___"; $subject="Новая заявка! ____"; $backurl="_______"; //------------------------------------ $name=$_POST['name']; $email=$_POST['email']; $msg=$_POST['message']; $phone=$_POST['phone']; $source= $uri=$_POST['uri']; $site=$_POST['site']; //--------------------------------// mail("$adminemail", "Отправитель: \n $sender", "Тема: \n $subject", "Имя: \n $name", "Телефон: \n $phone", "Источник: \n $source", "Сайт: \n $site", "Страница входа: \n $uri"); //------------------// print "<script language='Javascript'><!-- function reload() {location = \"$backurl\"}; setTimeout('reload()', 3000); //--></script> <p>Thank you for leaving the application. We will call you soon!</p>"; exit; ?> 


Flips to the contents of the file post.php when you click on submit. And nothing comes to the specified email.

Thanks if someone tell me

  • What does "throws" mean? The form contains post.php, so this file should process the request and it should be in the address bar of the browser after processing. - sercxjo
  • also no data is sent to the specified email - Ksu Lyguta
  • Is the resulted .php exactly post.php? And is it on the server in the same directory as the file with the form? - sercxjo
  • Yes, all in the same directory - Ksu Lyguta
  • Did you mean to say that the contents of this file are displayed instead of the result of its execution? - sercxjo

1 answer 1

mail(); function mail(); has a prototype

 bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] ); 

Your parameters do not quite match.

Regarding the work of your script, and where do you run it? On a hosting or local server? It happens that hosting does not support sending mail (especially often it is for free).

  • 2
    Class names with spaces do not exist. An element can be assigned several classes and all of them are written with a space. exit is a construct, the same as echo or print and allows for syntax without parentheses. In general, you would learn a little bit of "mat.chast", before giving advice to others. - Deonis
  • @Dionis yes, I’m not sure about the classes. - Nik
  • I corrected the print exactly, thanks :)) for the correct syntax of this or that I will not speak, because today I see all this for the first time and try to search. And yes, on a free hosting I try to launch - Ksu Lyguta
  • @KsuLyguta about print I was wrong. Can be used with or without brackets. Just like exit; . - Nik
  • understood, thanks - Ksu Lyguta