1

I have a url link that has value of the id and process when clicked. code:

<?php
 <a href='settoActive.php?id=".$row['id']."&process=actives' style='font-size:15px;' name='active' value=".$row['id']." class='btn btn-info' />ACTIVE</a>
?>

<a href='settoActive.php?id=".$row['id']."&process=inactive' style='font-size:15px;' name='active' value=".$row['id']." class='btn btn-info' />inactive</a>

and this is where the page will be redirected to:

<?php

$value = $_GET['process'];

echo "<script> alert(".$value.");</script> ";


if($_GET['proc']="actives"){
$id = $_GET['id'];
$mysqli = new mysqli('10.237.2.152','root','c0k3float','monitoring');
$results = $mysqli->query("UPDATE  Shipment_Target SET status='Active' where id=".$id."  ") or mysqli0;


echo "<script>alert('Activessss!');  </script>";
//location.replace('addmodel.php')

}

if($_GET['process']="inactive"){
    $id = $_GET['id'];
$mysqli = new mysqli('10.237.2.152','root','c0k3float','monitoring');
$results = $mysqli->query("UPDATE  Shipment_Target SET status='Inactive' where id=".$id."  ") or mysqli0;


echo "<script>alert('Inactive!'); </script>";
}

// location.replace('addmodel.php')



?>

The problem is the 2 if condition trigger and why it is triggering at the same time?

2 Answers2

0

There are 3 mistakes noticed... 2 places '==' operator and 1 place GET variable name 'process'.

$value = $_GET['process'];

echo "<script> alert(".$value.");</script> ";


if($_GET['process']=="actives"){
$id = $_GET['id'];
$mysqli = new mysqli('10.237.2.152','root','c0k3float','monitoring');
$results = $mysqli->query("UPDATE  Shipment_Target SET status='Active' where id=".$id."  ") or mysqli0;


echo "<script>alert('Activessss!');  </script>";
//location.replace('addmodel.php')

}

if($_GET['process']=="inactive"){
    $id = $_GET['id'];
$mysqli = new mysqli('10.237.2.152','root','c0k3float','monitoring');
$results = $mysqli->query("UPDATE  Shipment_Target SET status='Inactive' where id=".$id."  ") or mysqli0;


echo "<script>alert('Inactive!'); </script>";
}

// location.replace('addmodel.php')



?>
Naga
  • 2,190
  • 3
  • 16
  • 21
0

Problem in the html code, try following code

<a href='settoActive.php?id=<?php echo $row['id']; ?>&process=actives' style='font-size:15px;' name='active' value="<?php echo $row['id']; ?>" class='btn btn-info' />ACTIVE</a>

<a href='settoActive.php?id=<?php echo $row['id']; ?>&process=inactive' style='font-size:15px;' name='active' value="<?php echo $row['id']; ?>" class='btn btn-info' />inactive</a>
Elby
  • 1,624
  • 3
  • 23
  • 42