passing variable do not display value in PHP

Discussion of programming on Linux, including shell scripting, perl, python, c/c++, mono, java. Whatever tickles your fancy.
Post Reply
mohdali2
Havaldaar
Posts: 125
Joined: Sun Jan 26, 2003 4:54 pm

passing variable do not display value in PHP

Post by mohdali2 »

I am using PHP 4 with Apache 2. I have a very misterious
problem.

I make a file with the name of job_simple.html the code is
as follows:

<HTML>
<!-- jobapp_simple.html -->
<BODY>
<H1>Phop's Bicycles Job Application</H1>
<P>Are you looking for an exciting career in the world of cyclery?
Look no further!
</P>

<FORM NAME='frmjobapp' METHOD=post ACTION="/phppractice/jobapp_simple_action.php">
Please enter your name:
<INPUT NAME="applicant" type="text"><BR>
<INPUT NAME="enter" TYPE="submit" VALUE="Enter">
</FORM>
</BODY>
</HTML>

Now when I enter any string in the name field and press enter
jobapp_simple_action.php prints only Welcome the $applicant
value does not show by browser. The code of
jobapp_simple_action.php is as follows:

<HTML>
<!-- jobapp_simple_action.php -->
<BODY>
<P>Welcome <?php echo ($applicant); ?></p>
</BODY>
</HTML>

Anyone knows please help me, thanks in advance.

Regards
Muhammad Ali
fawad
Site Admin
Posts: 918
Joined: Wed Aug 07, 2002 8:00 pm
Location: Addison, IL
Contact:

Post by fawad »

AOA,
The thing is that the newer PHP installs set register_global to false. That means that $applicant isnt set in the target page. To get the value of the variable, use
$_POST["applicant"]
instead of
$applicant

You could set register_global to true, but I really wouldn't recommend it unless you're inheriting a huge codebase with constructs like you mentioned.
Post Reply