@UncleMisha

Открытие страницы после отправки формы?

Форма отправляет данные в amocrm. Все работает отлично, но вот возник вопрос как открыть другую страницу после отправки формы? Вот сама форма:
<form action="send-contact.php" method="POST">
			<h1>Заказать бесплатный звонок</h1>
			<p>заполните форму и мы перезвоним вам в течение 5 мин</p>
			<input type="hidden" name="site" value="ramspromo.kz">
			<input type="hidden" name="form_subject" value="Заказал бесплатный звонок (header)">
			<input type="hidden" name="utm_source" value="<?php echo isset($_GET['utm_source']) ? $_GET['utm_source'] : '' ;?>" />
			<input type="hidden" name="utm_medium" value="<?php echo isset($_GET['utm_medium']) ? $_GET['utm_medium'] : '' ;?>" />
			<input type="hidden" name="utm_campaign" value="<?php echo isset($_GET['utm_campaign']) ? $_GET['utm_campaign'] : '' ;?>" />
			<input type="hidden" name="utm_content" value="<?php echo isset($_GET['utm_content']) ? $_GET['utm_content'] : '' ;?>" />
			<input type="hidden" name="utm_term" value="<?php echo isset($_GET['utm_term']) ? $_GET['utm_term'] : '' ;?>" />
			<input type="text" name="email" placeholder="емайл"><br>
			<input type="text" name="name" placeholder="Ваше имя"><br>
			<input type="text" name="phone" placeholder="Контактный телефон" class="mask-phone" required><br>
			<button type="submit" class="btn btn-success">Заказать бесплатный звонок</button>
		</form>

Ниже код отвечающий за отправку данных в amocrm:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">

<?php
require __DIR__ . '/vendor/autoload.php';

if(isset($_POST['phone'])) {

  try {
    
    // Создание клиента
    $subdomain = '';            // Поддомен в амо срм
    $login     = '';            // Логин в амо срм
    $apikey    = '';            // api ключ


    $amo = new \AmoCRM\Client($subdomain, $login, $apikey);

    // Вывести полученые из амо данные
    // echo '<pre>';
    // print_r($amo->account->apiCurrent());
    // echo '</pre>';

    // создаем лида
    $lead = $amo->lead;
    $lead['name'] = $_POST['product_name'];
    // $lead['responsible_user_id'] = 2462338; // ID ответсвенного 
    // $lead['pipeline_id'] = 1207249; // ID воронки

    // $lead->addCustomField(305117, [ // ID  поля в которое будт приходить заявки
    //     [$_POST['city']], // сюда вписать значение из атрибута "name" пример: <input name="phone">
    // ]);

    $lead->addCustomField(595039, [
        [$_POST['utm_source']],
    ]);

    $lead->addCustomField(595041, [
        [$_POST['utm_medium']],
    ]);

    $lead->addCustomField(595043, [
        [$_POST['utm_campaign']],
    ]);

    $lead->addCustomField(595045, [
        [$_POST['utm_content']],
    ]);

    $lead->addCustomField(595047, [
        [$_POST['utm_term']],
    ]);

    $id = $lead->apiAdd();

    // Получение экземпляра модели для работы с контактами
    $contact = $amo->contact;

    // Заполнение полей модели
    $contact['name'] = isset($_POST['name']) ? $_POST['name'] : 'Не указано';
    $contact['linked_leads_id'] = [(int)$id];

    $contact->addCustomField(305117, [
      [$_POST['city']],
    ]);

    $contact->addCustomField(304033, [
      [$_POST['email'], 'PRIV'],
    ]);
    // Добавление нового контакта и получение его ID
    $id = $contact->apiAdd();


  } catch (\AmoCRM\Exception $e) {
      printf('Error (%d): %s' . PHP_EOL, $e->getCode(), $e->getMessage());
  }

}

?>


    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Ваша заявка успешно отправлена</title>

    <!-- Fonts -->
    <link href="https://fonts.googleapis.com/css?family=IBM+Plex+Sans" rel="stylesheet" type="text/css">

    <!-- Styles -->
    <style>
        html, body {
            background-color: #fff;
            color: #636b6f;
            font-family: 'IBM Plex Sans', sans-serif;
            font-weight: 100;
            height: 100vh;
            margin: 0;
        }

        .full-height {
            height: 100vh;
        }

        .flex-center {
            align-items: center;
            display: flex;
            justify-content: center;
        }

        .position-ref {
            position: relative;
        }

        .content {
            text-align: center;
        }

        .title {
            font-size: 20px;
            padding: 20px;
        }
    </style>
</head>
<body>
<div class="flex-center position-ref full-height">
    <div class="content">
        <div class="title">
            <br><span style="font-size:33px;font-weight:500;">Спасибо!</span><br><br>
            Ваша заявка успешно отправлена.<br>

            <?php if(isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER']) { ?>
                <br><br><a href="<?php echo $_SERVER['HTTP_REFERER']; ?>" style="text-decoration: none; border-bottom: 1px dotted">Вернуться назад</a>
             <?php } ?>
        </div>
    </div>
</div>

</body>
</html>

После отправки открывается именно эта страница с кодом выше, а конкретнее именно это:
<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Ваша заявка успешно отправлена</title>

    <!-- Fonts -->
    <link href="https://fonts.googleapis.com/css?family=IBM+Plex+Sans" rel="stylesheet" type="text/css">

    <!-- Styles -->
    <style>
        html, body {
            background-color: #fff;
            color: #636b6f;
            font-family: 'IBM Plex Sans', sans-serif;
            font-weight: 100;
            height: 100vh;
            margin: 0;
        }

        .full-height {
            height: 100vh;
        }

        .flex-center {
            align-items: center;
            display: flex;
            justify-content: center;
        }

        .position-ref {
            position: relative;
        }

        .content {
            text-align: center;
        }

        .title {
            font-size: 20px;
            padding: 20px;
        }
    </style>
</head>
<body>
<div class="flex-center position-ref full-height">
    <div class="content">
        <div class="title">
            <br><span style="font-size:33px;font-weight:500;">Спасибо!</span><br><br>
            Ваша заявка успешно отправлена.<br>

            <?php if(isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER']) { ?>
                <br><br><a href="<?php echo $_SERVER['HTTP_REFERER']; ?>" style="text-decoration: none; border-bottom: 1px dotted">Вернуться назад</a>
             <?php } ?>
        </div>
    </div>
</div>

Где что нужно написать в этом документе что бы открывалась совершено другая страница? Например spasibo.html. Заранее всех благодарю за ответы.
  • Вопрос задан
  • 561 просмотр
Решения вопроса 1
@UncleMisha Автор вопроса
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы