I do not know how to include a conditional in a input
that is shown through PHP.
I've tried with:
echo "<input type='text' name='status' placeholder='Introduce un estatus' value='"
. if(isset($_POST['guardar'])) {
$ubicacion;
} else {
$informacion_perfil['ubicacion'];
} . "'>";
It gives me an error: syntax error, unexpected 'if' (T_IF)
, but I do not know how to solve it, and evidently this way it would be showing all the conditional, when I only want to show $ubicacion
or $informacion_perfil['ubicacion']
depending on if one condition or another is fulfilled.
The only solution I found is this:
if(isset($_POST['guardar'])) {
echo "<input type='text' name='status' placeholder='Introduce un estatus' value='" . $status . "'>";
} else {
echo "<input type='text' name='status' placeholder='Introduce un estatus' value='" . $informacion_perfil['estado'] . "'>";
}
I would like to know if you can do the same code in just one line.