Hi There! Can you please help me with this.
On the first page of my page I created a Textbox named="Student", on the second page I just $_POST its name and the value goes through the textbox and now I wanted to show it Again on the Third box, I used the $_POST method again and an error occured, UNDEFINED VARIABLE!

Recommended Answers

All 5 Replies

Cyre,
write like this

if(!empty($_POST['student']))
                         {
                         $stud=$_POST['student'];
                         echo $stud;
                         }

Create session or save the student in DB and retrieve it to third page

use session variable...

$student=$_POST['student'];							// 
$_SESSION['student']=$student;

calling in the 3rd page

$student=$_SESSION['student'];

should work

Yes it is using session or DB but "Undefined variable " if it is checked by !empty will not show the error.

for avoid 'undefined var....' use error_reporting(E_ALL ^ E_NOTICE); on every top of your page,, use session_start(); echo $_session; thats all

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.