Guys please help me to solve the bug of below script. <?php //Check page incomes session_start(); if(isset($_SESSION['page'])){ $page1=$_SESSION['page']; } //If no data show as error 1 else{ echo '<br/>Error 1'; } //Start selection if($page1==2){ $title=('Testing title 1'); $description=('Testing description 1'); } elseif($page1==3){ $title=('Testing title 2'); $description=('Testing description 2'); } //If not in above range echo error 2 else{ echo $page1; echo '<br/>Error 2'; } //Register new sessions if(isset($title)){ $_SESSION['title']=$title; $_SESSION['description']=$description; header("location:about.php"); echo $title; } ?> PHP: This is written to select the correct title with description for the registered session parameter numbers.When $page1=2 or 3 this gives the following error(I need to register correct title session and description session to send to another page) Error 1 Notice: Undefined variable: page1 in C:\wamp\www\Kingmax\page_check.php on line 13 Notice: Undefined variable: page1 in C:\wamp\www\Kingmax\page_check.php on line 17 Notice: Undefined variable: page1 in C:\wamp\www\Kingmax\page_check.php on line 24 Error 2 HTML: But if those parameters out of selection range this prints incoming parameter and error correctly like below. 5 Error 2 HTML: So I commented the last session registration section and tell apache to print my title and description.In that case it returns the correct title with correct description.I think the problem is with my session section.This is what I did. //If not in above range echo error 2 else{ echo $page1; echo '<br/>Error 2'; } //Register new sessions /* if(isset($title)){ $_SESSION['title']=$title; $_SESSION['description']=$description; header("location:about.php"); echo $title; } */ echo $title; echo $description; ?> PHP: Then it returns Testing title 1Testing description 1 HTML: I can't understand the error guys please help me to solve this. Thank you
declare page1 first <?php //Check page incomes session_start(); $page1 = -1; if(isset($_SESSION['page'])){ $page1=$_SESSION['page']; } //If no data show as error 1 else{ echo '<br/>Error 1'; } //Start selection if($page1==2){ $title=('Testing title 1'); $description=('Testing description 1'); } elseif($page1==3){ $title=('Testing title 2'); $description=('Testing description 2'); } //If not in above range echo error 2 else{ echo $page1; echo '<br/>Error 2'; } //Register new sessions if(isset($title)){ $_SESSION['title']=$title; $_SESSION['description']=$description; header("location:about.php"); echo $title; } ?> PHP:
Thanx for your reply dude. I tried that then it shows this on the browser Error 1-1 Error 2 Notice: Undefined variable: title in C:\wamp\www\Kingmax\page_check.php on line 38 Notice: Undefined variable: description in C:\wamp\www\Kingmax\page_check.php on line 39 HTML:
Anyway, you can disable notices by only enabling some error reports. Try adding this on top of your codes. (Somewhere after <?php) error_reporting(E_ERROR | E_PARSE); Code (markup):
Ya guys it had so many issues I rewrote it with a free mind now it's working. Thank you very much for all your responses