Нужно вывести текст из адресной строки на страницу
Учу php второй день, поэтому ошибка скорее всего глупая. Нужна Ваша помощь!
html:
<div id='signin' class='modal-window'>
<h2 style='text-align:center'>Sign In</h2> <br>
<form action=/controller.php method 'post'>
<input type='hidden' name='page' value='StartPage'/>
<input type='hidden' name='command' value='SignIn'/>
<label class='modal-label'>Username:</label>
<input type='text' name='username' placeholder='Enter username'/><br>
<label class='modal-label'>Password:</label>
<input type='password' name='password' placeholder='Enter password'/><br><br>
<button type='submit' value='Submit'>Submit</button>
<button type='reset' value='Reset'>Reset</button>
<button id='cancel-signin' type='cancel' value='Cancel'>Cancel</button>
</form>
</div>
<div id='join' class='modal-window'>
<h2 style='text-align:center'>Join</h2><br>
<form action=/controller.php method='post'>
<input type='hidden' name='page' value='StartPage'/>
<input type='hidden' name='command' value='Join'/>
<label class='modal-label'>Username:</label>
<input type='text' name='username' placeholder='Enter username' /><br>
<label class='modal-label'>Password:</label>
<input type='password' name='password' placeholder='Enter password' /><br>
<label class='modal-label'>Email:</label>
<input type='text' name='email' placeholder='Enter email address' /><br><br>
<button type='submit' value='Submit'>Submit</button>
<button type='reset' value='Reset'>Reset</button>
<button id='cancel-join' type='cancel' value='Cancel'>Cancel</button>
</form>
</div>
PHP:
<html>
<body>
<?php
if (isset($_POST['page'])=='StartPage')// When commands come from StartPage
{
$command = isset($_POST['command']);
switch($command) { // When a command is sent from the client
case 'SignIn': // With username and password
echo "command" . $command;
$username = $_POST['username'];
echo "username". $username;
$password = $_POST['password'];
echo "password". $password;
break;
case 'Join':
echo "command" . $command;
$username = $_POST['username'];
echo "username". $username;
$password = $_POST['password'];
echo "password". $password;
}
}
?>
</body>
</html>
вывод такой нужен примерно:
command = SignIn(или Joinn), username = "введенный username", password = "какой-то пароль" и email если command == Join
Ответы (1 шт):
Автор решения: Максим Степанов
→ Ссылка
Функция isset определяет, была ли установлена переменная значением отличным от NULL и возвращает значение типа bool, поэтому у вас в $command не текст команды. Вам нужно просто заменить
$command = isset($_POST['command']);
на
$command = $_POST['command'];