Answer the question
In order to leave comments, you need to log in
How to make simple php handler for feedback form from one field?
The site has a feedback form with the "Phone" field and the send button. I need a PHP handler to send the entered phone number to my mail. How to implement it. I did not find a solution on the Internet - all the proposed scripts use several fields. Tried to remake them - did not work.
Answer the question
In order to leave comments, you need to log in
<form method="post">
<input type="text" name="phone">
<input type="submit">
</form>
<?php
if(($_POST['phone']) and (is_numeric($_POST['phone']))
mail("[email protected]", "New Phone: ".$_POST['phone'], $_POST['phone']);
?>
<?php
$number = $_POST['number']; //по желанию можно фильтровать или регуляркой проверить
if(!empty($number))
mail('[email protected]', 'Number from site', $number);
I did not find a solution on the Internet - all the proposed scripts use several fields.
$phone = $_POST['phone'];
$subject = "Тема";
$headers = "Content-Type: text/html; charset=UTF-8\r\n";
$message = "Текст письма";
$to = "[email protected]";
$res = mail($to, $subject, $message, $headers );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question