The task is as follows: the visitor fills in the form (name and phone number) and the data is sent by the post method, after which he is redirected to another page, where he needs to click or not to press the button. When you click a button, this data is also redirected by the post method. And here is how to write this data into the second form that the visitor sends (name and telephone, for example)
1 answer
Use sessions . In PHP, there is a super-global $ _SESSION array. You can go there all you need to write. (below is an example from the documentation)
<?php // page1.php session_start(); echo 'Добро пожаловать на страницу 1'; $_SESSION['favcolor'] = 'green'; $_SESSION['animal'] = 'cat'; $_SESSION['time'] = time(); // Работает, если сессионная cookie принята echo '<br /><a href="page2.php">page 2</a>'; // Или можно передать идентификатор сессии, если нужно echo '<br /><a href="page2.php?' . SID . '">page 2</a>'; ?>
After viewing page1.php
, the second page2.php page will miraculously get all the session data.
<?php // page2.php session_start(); echo 'Добро пожаловать на страницу 2<br />'; echo $_SESSION['favcolor']; // green echo $_SESSION['animal']; // cat echo date('Y md H:i:s', $_SESSION['time']); // Можете тут использовать идентификатор сессии, как в page1.php echo '<br /><a href="page1.php">page 1</a>'; ?>
- Yes, this is exactly what you need. - Alexander Chernousov
- Yes, this is exactly what you need. But surprisingly, the fact is - this is how it is displayed on the server fr79630j.bget.ru/index.php - Alexander Chernousov
- @AlexanderChernousov if you copied the code as it is, then it is not displayed correctly in you, two more fields should have appeared there - Farkhod Daniyarov pm
|