Answer the question
In order to leave comments, you need to log in
Why is the php contact form throwing an error?
Good day !
I am writing my first landing page, the problem is in the feedback form.
after filling in and pressing the "send" button, it redirects to the page localhost:3000/php/send.php
where there is one term: Cannot POST /php/send.php
and an error occurs in the console:
Refused to execute inline script because it violates the following Content Security Policy directive: "default-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-KpHv3zgivMSB4dPnfYfqMt2lBibsYvM36EdoBBAsfbM='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
<?php
$back = "<p><a href=\"javascript: history.back()\">Вернуться назад</a></p>";
if(!empty($_POST['name']) and !empty($_POST['phone']) and !empty($_POST['mail'])
and !empty($_POST['message'])){
$name = trim(strip_tags($_POST['name']));
$phone = trim(strip_tags($_POST['phone']));
$mail = trim(strip_tags($_POST['mail']));
$message = trim(strip_tags($_POST['message']));
mail('[email protected]', 'Пледы',
'Вам написал: '.$name.'<br />Его номер: '.$phone.'<br />Его почта: '.$mail.'<br />
Его сообщение: '.$message,"Content-type:text/html;charset=windows-1251");
echo "Ваши данные успешно отправлено!<Br> Вы получите ответ в
ближайшее время<Br> $back";
exit;
}
else {
echo "Для отправки сообщения заполните все поля! $back";
exit;
}
?>
form(method="post" action="../../php/send.php")
label(for="name") Имя:
input(maxlength="30" type="text" name="name")
label(for="phone") Телефон:
input(maxlength="30" type="text" name="phone")
input(type="submit" value="Отправить")
function checkForm(form) {
var name = form.name.value;
var n = name.match(/^[A-Za-zА-Яа-я ]*[A-Za-zА-Яа-я ]+$/);
if (!n) {
alert("Имя введено неверно, пожалуйста исправьте ошибку");
return false;
}
var phone = form.phone.value;
var p = phone.match(/^[0-9+][0-9- ]*[0-9- ]+$/);
if (!p) {
alert("Телефон введен неверно");
return false;
}
return true;
}
Answer the question
In order to leave comments, you need to log in
Because for php to work you need a web server with a php interpreter maybe?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question