2
I know it is possible to "call" the name of a form in a php file. But in a php file, it is possible to "call" a class made in a form to get the same effect of "calling" the name, i.e., how to send data from a form to a php file through a class ?
Specifying, to send via name I use the following php code:
$variável = $_POST['name'];
But how do I if instead of name is a class ?
OBS 1; I’ve tried to just replace the name with the class, but it didn’t work.
OBS 2; I don’t have access to the form file, so I can’t just enter a name to use the aforementioned code.
Form:
<table>
<form name="form" method="post" action="">
<tr>
<td>
<label>Email</label>
</td>
<td>
<input type="text" name="email">
</td>
</tr>
<tr>
<td>
<label>Senha</label>
</td>
<td>
<input type="password" name="senha">
</td>
</tr>
<input type="submit" class="botao-login" value="Login">
</form>
</table>
Note that the login button does not have the name. I am trying to do a php function for login authentication, whose function is "isset". Namely, by pressing the button the following php code runs:
Php code
<?php
$usuario = $_POST['usuario'];
$senha = $_POST['senha'];
$botao = $_POST['é aqui que costumo por o name do botão'];
if (isset($botao)) {
if ($usuario == "" or $senha == "") {
$mensagem = "Campo em branco";
} elseif ($usuario != $_COOKIE['usuario'] or $senha != $_COOKIE['senha']) {
$mensagem = "Usuáriorio ou senha inválido";
} elseif ($usuario == $_COOKIE['usuario'] && $senha == $_COOKIE['senha'] && $_COOKIE['tipo_conta'] == "administrador") {
header("Location:php/administrador.php");
} elseif ($usuario == $_COOKIE['usuario'] && $senha == $_COOKIE['senha'] && $_COOKIE['tipo_conta'] == "registrado") {
header("Location:php/registrado.php");
} elseif ($usuario == $_COOKIE['usuario'] && $senha == $_COOKIE['senha'] && $_COOKIE['tipo_conta'] == "indefinido") {
header("Location:php/indefinido.php");
}
}
?>
The php code is not on the same page as the form.As said before, the php code is executed by pressing the button, but for the code to work, it is possible that it has a name so that I can use the code $variável = $_POST['name'];
.Is there any php code for the "isset" function to work without the need for a name ?
Why check if that button was clicked? This same php receives data from other forms?
– bfavaretto
complicated to understand, but it is not possible for PHP to see the class attribute of an HTML tag this way.
– Daniel Omine