Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- const FINEL_STEP = 4;
- $inputSteps = [];
- $step1 = ['login' => '<input type="%2$s" name="login" value="%1$s" />',
- 'age' => '<input type="%2$s" name="age" value="%1$s" />',
- 'passwd' => '<input type="%2$s" name="passwd" value="%1$s" />'
- ];
- $step2 = ['first_name' => '<input type="%2$s" name="first_name" value="%1$s" />',
- 'second_name' => '<input type="%2$s" name="second_name" value="%1$s" />',
- 'sex' => '<input type="%2$s" name="sex" value="%1$s" />'
- ];
- $step3 = ['city' => '<input type="%2$s" name="city" value="%1$s" />',
- 'street' => '<input type="%2$s" name="street" value="%1$s" />',
- 'home' => '<input type="%2$s" name="home" value="%1$s" />'
- ];
- $step4 = ['postcode' => '<input type="%2$s" name="postcode" value="%1$s" />',
- 'phone' => '<input type="%2$s" name="phone" value="%1$s" />',
- 'nubmerCard' => '<input type="%2$s" name="nubmerCard" value="%1$s" />'
- ];
- $inputSteps = array(1 => $step1, 2 => $step2, 3 => $step3, 4 => $step4);
- $step = !empty($_GET['step']) ? $_GET['step'] : 1;
- $fields = [];
- $fields['login'] = !empty($_GET['login']) ? $_GET['login'] : '';
- $fields['age'] = !empty($_GET['age']) ? $_GET['age'] : '';
- $fields['passwd'] = !empty($_GET['passwd']) ? $_GET['passwd'] : '';
- $fields['first_name'] = !empty($_GET['first_name']) ? $_GET['first_name'] : '';
- $fields['second_name'] = !empty($_GET['second_name']) ? $_GET['second_name'] : '';
- $fields['sex'] = !empty($_GET['sex']) ? $_GET['sex'] : '';
- $fields['city'] = !empty($_GET['city']) ? $_GET['city'] : '';
- $fields['street'] = !empty($_GET['street']) ? $_GET['street'] : '';
- $fields['home'] = !empty($_GET['home']) ? $_GET['home'] : '';
- $fields['postcode'] = !empty($_GET['postcode']) ? $_GET['postcode'] : '';
- $fields['phone'] = !empty($_GET['phone']) ? $_GET['phone'] : '';
- $fields['nubmerCard'] = !empty($_GET['nubmerCard']) ? $_GET['nubmerCard'] : '';
- ?>
- <!doctype html>
- <html lang="en">
- <head>
- <!-- Required meta tags -->
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <!-- Bootstrap CSS -->
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
- <title>Lesson 1</title>
- </head>
- <body>
- <?php
- if ($step > FINEL_STEP) {
- echo 'Благодарим за предоставленную информацию:';
- echo '<pre>';
- print_r($fields);
- echo '</pre>';
- exit;
- }
- if (empty($inputSteps[$step])) $step = 1;
- $next_step = $step+1;
- ?>
- <div class="container">
- <div class="row">
- <form action="/lesson1.php" method="GET">
- <?php
- echo '<h2>Шаг '.$step.' из '.FINEL_STEP.'.</h2><p>';
- for ($i = 1; $i < $next_step; $i++) {
- foreach ($inputSteps[$i] as $field=>$input) {
- if ($i < $step) {
- '<div class="col-md-12 col-sm-12">';
- echo sprintf($input,$fields[$field], 'hidden');
- }else{
- echo $field.': ';
- echo sprintf($input, $fields[$field], 'text');
- '</div>';
- }
- }
- echo '</p>';
- }
- echo '<input type="hidden" name="step" value="'.$next_step.'" />';
- ?>
- <?php if ($step != FINEL_STEP): ?>
- <button>Перейти к шагу <?= $next_step ?></button>
- <?php else: ?>
- <button>Завершить опрос!</button>
- <?php endif; ?>
- </div>
- </form>
- </div>
- <!-- Optional JavaScript -->
- <!-- jQuery first, then Popper.js, then Bootstrap JS -->
- <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement