Redirect pages using if, else if, and else attributes What is wrong? [closed]

0

My php code

<?php

include "conectar.php";


//comando para iserir dados direto do formul?rio para o banco de dados

$nome=$_POST["nome"];
$cpf=$_POST["cpf"];
$identidade=$_POST["identidade"];
$telefone=$_POST["telefone"];
$celular=$_POST["celular"];
$email=$_POST["email"];
$cep=$_POST["cep"];
$endereco=$_POST["endereco"];
$complemento=$_POST["complemento"];
$bairro=$_POST["bairro"];
$cidade=$_POST["cidade"];
$uf=$_POST["uf"];
$sexo=$_POST["sexo"];
$idade=$_POST["identidade"];
$peso=$_POST["peso"];
$individual=$_POST["individual"];
$tresvidas=$_POST["tresvidas"];
$cincovidas=$_POST["cincovidas"];


$sql="INSERT INTO cadsolidario VALUES ('$nome', '$cpf', '$identidade', '$telefone', '$celular', '$email', '$cep', '$endereco', '$complemento', '$bairro', '$cidade', '$uf', '$sexo', '$idade', '$peso', '$individual', '$tresvidas', '$cincovidas')";
$RES=mysqli_query($con,$sql);
$num=mysqli_affected_rows($con);

if($num = "tresvidas"){
include('busca.php');

}else if($num = "cincovidas"){
    include('index.php');

}else{
     include('consulta-consultas.php');
}

?>

note: you are entering the data correctly. But you are not redirecting what I should do? Thanks!

    
asked by anonymous 16.11.2017 / 19:10

1 answer

1

The mysqli_affected_rows() returns the NUMBER of affected rows, however, you are comparing with a string.

I also noticed that you are using = in your if . What's wrong is = is used in comparisons in PHP while == is used to see if one value is exactly the same as the other.

    
16.11.2017 / 19:23