使用条件传递值的未识别索引

使用条件传递值的未识别索引

问题描述:

I have a problem,

if($_POST['carrier'] == 'LBC') {
    $_POST['payment'] =='BPI';
}
else if($_POST['carrier'] == 'PickUp') {
    $_POST['payment'] == 'PickUp';
}

if (isset($_POST['order'])) {
    $_SESSION['carrier'] = $_POST['carrier'];
    $_SESSION['payment'] = $_POST['payment'];
}

my $_POST['payment'] is causing an unidentified index problem but my carrier is not, maybe because i used a form using the carrier on the previous page.

how do i fix this problem? because i need to pass the value for the payment. only the carrier is passed from the previous form, but here in this page, i need to pass a value to the $_POST or at least in the $_SESSION but it does not work for me.

i dont know what's wrong.

我遇到了问题, p>

  if($ _ POST [  'carrier'] =='LBC'){
 $ _POST ['payment'] =='BPI'; 
} 
else if($ _ POST ['carrier'] =='PickUp'){
 $  _POST ['payment'] =='PickUp'; 
} 
 
if(isset($ _ POST ['order'])){
 $ _SESSION ['carrier'] = $ _POST ['carrier'];  
 $ _SESSION ['payment'] = $ _POST ['payment']; 
} 
  code>  pre> 
 
 

我的 $ _ POST ['payment'] 导致一个未识别的索引问题,但我的运营商不是,可能是因为我使用了上一页使用运营商的表单。 p>

我该如何解决这个问题? 因为我需要传递付款的价值。 只有运营商从上一个表单传递,但是在这个页面中,我需要将值传递给 $ _ POST code>或者至少在 $ _ SESSION code>中传递,但它确实 不适合我。 p>

我不知道什么是错的。 p> div>

No you must use the $_POST that way, its only going to be set on form submission.

$payment = null;
if($_POST['carrier'] == 'LBC'){
    $payment = 'BPI';
}

else if($_POST['carrier'] == 'PickUp'){
    $payment = 'PickUp';
          // ^ assignment operator (=) not (==) equality
}

if (isset($_POST['order'])){
    $_SESSION['carrier'] = $_POST['carrier'];
    $_SESSION['payment'] = $payment;
}