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.

passing variable do not display value in PHP

Postby mohdali2 » Thu Aug 19, 2004 3:30 am

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
mohdali2
Havaldaar
 
Posts: 125
Joined: Sun Jan 26, 2003 4:54 pm

Postby fawad » Thu Aug 19, 2004 9:09 am

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.
fawad
Site Admin
 
Posts: 918
Joined: Wed Aug 07, 2002 8:00 pm
ICQ: 17672437
Website: http://www.fawad.net
WLM: fawadhalim@hotmail.com
Yahoo Messenger: fawad2048
AOL: fawadhalim
Location: Addison, IL


Return to “%s” Programming

Who is online

Users browsing this forum: No registered users and 2 guests

cron