duanjue6584 2015-09-22 10:43 采纳率: 100%
浏览 26
已采纳

预填充SESSION [SESS_PREFIX

On my home page there is a link to another page.. when I go from my homepage to let say the order page.. the order page is working..

But when I go to my order page directly.. I got an error:

Notice: Undefined index: banner_type on line 33

// line 33

$_SESSION[SESS_PREFIX .'type'] = $_POST['banner_type'];

the prefill must be kozijnen.. what code can i use for the order page to work. when I visit it directly?

if ( isset ( $_SESSION[SESS_PREFIX .'type'] ) ) {



    // check flyer

    if ( $_SESSION[SESS_PREFIX .'type'] == "kozijnen" ) {

I need to hard code the kozijnen into my order page..

this is a part off the code from my home page:

$value ) { // output //echo ''; } ?> Postcode Straal 10 km 25 km 50 km 100 km Overal Werkzaamheden $value ) { echo ''. $value .''; } ?> --->

and this from my order page..

/ chek sessions step1

if ( !isset($_SESSION[SESS_PREFIX .'postal']) OR !isset($_SESSION[SESS_PREFIX .'radius']) OR !isset($_SESSION[SESS_PREFIX .'type']) ) {

// fill in

$_SESSION[SESS_PREFIX .'type'] = $_POST['banner_type'];




// check isset submit

if ( isset ( $_POST['banner_search_submit'] ) ) {

    header("Location: ". $_SERVER['REQUEST_URI']);

}

}

// check step 2

if ( isset ( $_POST['gotostep2'] ) OR isset ( $_POST['adjuststep1'] ) ) {

$_SESSION[SESS_PREFIX .'type'] = $_POST['type'];

}

-- / check type isset

//echo ( isset ( $$_SESSION[SESS_PREFIX .'type'] = "kozijnen" ) {

if ( isset ( $_SESSION[SESS_PREFIX .'type'] ) ) {

// check flyer

if ( $_SESSION[SESS_PREFIX .'type'] == "kozijnen" ) {
  • 写回答

1条回答 默认 最新

  • doujianwan7570 2015-09-22 11:30
    关注

    Deducted from the comments, what you were looking for is called a ternary operator

    It can be used in a different set of ways but in general it's used to assign a "default" value if no value is present.

    And one of the way it works are like so:

    $value = (CHECK) ? <VALUE IF CHECK PASSES> : <VALUE IF CHECK FAILS>;
    

    As stated in comments you should / could use it like so:

    $_SESSION[SESS_PREFIX .'type'] = isset($_SESSION[SESS_PREFIX .'type']) ? $_SESSION[SESS_PREFIX .'type'] : 'kozijnen';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?