M
M
Marina Shutova2015-04-03 20:44:05
PHP
Marina Shutova, 2015-04-03 20:44:05

What is the correct way to redirect the user to the "Thank you for submitting" page after submitting the form?

Good evening. The site has a form for sending applications, sending is implemented using a php script. Here is the code

<?php

$mal = $_POST['email'];
$url = $_SERVER['HTTP_REFERER']."success";

if(!empty($mal))
{
  $message = '';

    $message .= 'Email: '.$mal."<br/>";
  
  // To send HTML mail, the Content-type header must be set
  $headers  = 'MIME-Version: 1.0' . "\r\n";
  $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
  
  mail("[email protected]", "Заявка", $message, $headers);
  header("Location: $url");
}
?>

After submitting the form, the user is taken to example.com/success . Customers complain that after clicking on the "Send" button, nothing happens, but applications are received by mail. Tested: everything works for me. Please let me know what could be the cause and solution of this problem. Thanks in advance!!!)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
X
xmoonlight, 2015-04-03
@xmoonlight

what's stopping you from doing this
$url="/success/";:

F
FanatPHP, 2015-04-03
@FanatPHP

HTTP_REFERER should never be used in site mechanics.
The easiest way is to process all forms at the same address where they are shown.
If this is difficult, then write the return url in a hidden form field

D
DieZz, 2015-04-03
@DieZz

Maybe so?
$url = $_SERVER['HTTP_REFERER']."/success";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question