php - Send e-mail with page name in it -
i have contact form, e-mails composed , sent using php. use separate php file that.
$errors = ''; $myemail = 'mail@gmail.com';// if(empty($_post['name']) || empty($_post['email']) || empty($_post['phone'])) { $errors .= "\n Будь ласка, заповніть усі поля"; } $name = $_post['name']; $email_address = $_post['email']; $message = $_post['phone']; $page = getrequesturi(); if (!preg_match( "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email_address)) { $errors .= "Некоректна адреса e-mail"; } if( empty($errors)) { $to = $myemail; $email_subject = "contact form submission: $name"; $email_body = "Нове замовлення туру: $page". "Деталі:\n Ім'я: $name \n email: $email_address \n Телефон \n $message"; $headers = "from: $myemail\n"; $headers .= "reply-to: $email_address"; mail($to,$email_subject,$email_body,$headers); //redirect 'thank you' page header('location: contact-form-thank-you.html'); }
i need put such forms on different pages. , there should information page on form submitted in message sent e-mail.
is there possibility without creating separate php files every page? in other words how can name (or url) of page, on form submitted?
you can current request uri using $_server['request_uri']
.
assuming script located @ http://example.com/some/page-here/more
, $_server['request_uri']
/some/page-here/more
.
Comments
Post a Comment