-1
I am doing so and when it is to print the result(After the user selects the Submit in another index), nothing appears. It is empty. WHERE IT RECEIVES DATA VIA POST FROM THE RADIO TYPE FORM AND SETS OUT THE CONDITIONS:
<?php
// Recebendo as respostas do Usuário
$perfil = $_POST["pergunta1"];
$condicao = $_POST["pergunta2"];
//Iniciando as variáveis
$cpu = "cpu";
$rom = "rom";
$ram = "ram";
// Primeiro caso: Perfil de uso - Dia a dia
if ($perfil == "diadia" && $condicao == "economico") {
$cpu = "Intel Celeron";
$rom = "HDD 300GB";
$ram = "2GB DDR3";
} elseif ($perfil == "diaadia" && $condicao == "normal") {
$cpu = "Intel Core i3";
$rom = "HDD 500GB";
$ram = "4GB DDR3";
}
// Segundo caso: Perfil de uso - Trabalho
elseif ($perfil == "trabalho" && $condicao == "economico") {
$cpu = "Intel Core i3";
$rom = "HDD 500GB";
$ram = "4GB DDR3";
} elseif ($perfil == "trabalho" && $condicao == "normal") {
$cpu = "Intel Core i5";
$rom = "HDD 1TB";
$ram = "8GB DDR3";
$video = "2GB";
}
// Terceiro caso: Perfil de uso - Edição
elseif ($perfil == "edicao" && $condicao == "economico") {
$cpu = "Intel Core i5";
$rom = "HDD 1TB";
$ram = "8GB DDR3";
$video = "2GB";
} elseif ($perfil == "edicao" && $condicao == "normal") {
$cpu = "Intel Core i7";
$rom = "HDD 1TB";
$ram = "12GB DDR3";
$video = "4GB";
};?>
WHERE THE USER WILL BE SHOWN THE SETTINGS ACCORDING TO THE CONDITIONS:
<section class="page-section bg-primary text-white mb-0">
<div class="container">
<div class="divider-custom divider-light">
<div class="divider-custom-line"></div>
<div class="divider-custom-icon"><i class="fas fa-star"></i></div>
<div class="divider-custom-line"></div>
</div>
<!-- About Section Content-->
<div class="row">
<?php
echo "Processador: $cpu " . "<br>";
echo "Armazenamento: $rom " . "<br>";
echo "Memoria RAM: $ram " . "<br>";
if ($perfil = "edicao" && $condicao = "economico"){
echo "Placa de video dedicada: $video" . "<br>";
} elseif ($perfil = "edicao" && $condicao = "normal"){
echo "Placa de video dedicada: $video " . "<br>";
};
?>
</div>
</div>
</section>
Dude, you got a problem, pressing Ubmit, you get 500
– Antonio Figueiredo
In this case, you need to see the Apache logs to identify the cause.
– Marcos Alexandre
Fatal error: Cannot use Temporary Expression in write context in /home/defaultwebsite/public/descubraseupc/form/index.php on line 33
– Antonio Figueiredo
Line 33: $computers = ['diaadia']['economico']['cpu'] = "Intel Celeron";
– Antonio Figueiredo
There was an error in the assignments, but I already corrected the answer. You can check, but essentially, it was assigning wrong
– Marcos Alexandre
/home/defaultwebsite/public/descubraseupc/form/index.php on line 63 Notice: Undefined index: in /home/defaultwebsite/public/descubraseupc/form/index.php on line 63 Notice: Undefined variable: condicao in /home/defaultwebsite/public/descubraseupc/form/index.php on line 63 Notice: Undefined variable: perfil in /home/defaultwebsite/public/descubraseupc/form/index.php on line 64 Notice: Undefined variable: condicao in /home/defaultwebsite/public/descubraseupc/form/index.php on line 64
– Antonio Figueiredo
Line 63: $ram = $computers[$profile][$condition]['ram']; Line 64: if(isset($computers[$profile][$condition]['video'])){
– Antonio Figueiredo
Remembering that I made a change 62 and 63, because it was the other way around, where it was supposed to be "ram" was "rom"
– Antonio Figueiredo
This is because the value of $profile and $condition did not come.Make sure the data is coming correctly from the form.
– Marcos Alexandre
Ok, solved. However, one of the initial problems continues. It did not print the results of the variables, the other strings yes, as "Processor: "
– Antonio Figueiredo
It is working here: http://sandbox.onlinephpfunctions.com/code/ce1554e10c213deac04c5268abcb7e091159d1528 Please check carefully the rest of your code... And if it helped, please mark the answer.
– Marcos Alexandre
Okay, thanks for your help!
– Antonio Figueiredo
Dispose. We are here to help.
– Marcos Alexandre