S
S
Stacy None2017-11-07 11:22:42
PHP
Stacy None, 2017-11-07 11:22:42

How to create a form with a field for php code?

<?php
// Задаем пароль
$password = "111";

// Берем ссылку для редиректа из ?url=*
$link = array_key_exists("url", $_GET) ? $_GET['url'] : "http://google.com";

// Проверяем сабмит формы с паролем
if (array_key_exists("password", $_POST)) {
    // Проверяем введенный пароль
    if (strcasecmp($_POST['password'], $password) == 0) {
        // Пароль совпал, редиректим
        header("Location: {$link}");
    }else{
        // Пароли не совпали показываем ошибку
        require_once 'error.php';
    }
}else{
    // Показываем форму для ввода пароля
    require_once 'form.php';
}
?>

People! Please help me to correctly create the form.php and error.php files for this code.
I don't know how to correctly write the password field and have the password sent to this code and checked.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question