1

Good day to everyone, I am currently facing a problem whereby I want to send selected row of data to either Payment Module or Delivery Module based on the variable selected_option. If the user selected Refund, this row of data which has been APPROVE will be sent to Payment Module for further processing, vise versa. Below are the code I am currently at.

if(isset($_POST['btnApprove']))
{
  $selectedItem = $_POST['selectitemradio'];
  echo $selectedItem;
  $sql = "UPDATE `returntable` SET `return_status`='APPROVED' WHERE return_id= '$selectedItem'";

  if(!mysqli_query($db,$sql)){
    echo "failed";
  }else {

    if (`return_option` == 'Refund')
    { 
        echo 'Bring Selected Row Of Data To Payment Module';
    } elseif (`return_option` == 'Replacement') {
        echo 'Bring Selected Row of Data To Delivery Module';
    }
    // header("refresh: 0.0000000000000000000000001");
  }

}
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Jeff Boon
  • 11
  • 7
  • 1
    Hi there. I'm a little unsure what you're asking for. Do you want to `UPDATE` a different table in your database based on the `return_option` condition, or do you want to *redirect* the user to a different location based on that conditional? – Obsidian Age Nov 29 '18 at 02:25
  • [No SQL injection](https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) please. What is `return_option`? – danblack Nov 29 '18 at 02:26
  • @ObsidianAge based on the condition, the page will work in background to direct the row of data to a different page/ module. As I am working on Return Module and my colleague are working on Payment & Delivery Module. – Jeff Boon Nov 29 '18 at 02:27
  • @danblack **return_option** is a variable that display either **Refund** or **Replacement**. – Jeff Boon Nov 29 '18 at 02:29
  • why are there ticks `\`` around `return_option` ? – Funk Forty Niner Nov 29 '18 at 02:53
  • @FunkFortyNiner then should I do it like this `$return_option`? – Jeff Boon Nov 29 '18 at 04:59

1 Answers1

0

Change the code. You have chose wrong variable i think. What is the variable you chose for your selected option. i'm not sure . If it is $selected_option then write this code

if ($selected_option == 'Refund')
    { 
        echo 'Bring Selected Row Of Data To Payment Module';
    } elseif ($selected_option == 'Replacement') {
        echo 'Bring Selected Row of Data To Delivery Module';
    }