Hi,
I need help passing variables in php. I have an html page describing a job with an id number(jobdescription.html).

-when the user clicks on a submit button, I want to open another html page (jobsubmit.html) with a form and have the job id autofill into a form field named 'job_id'.

-further, when I hit submit on jobsubmit.html page, I want the job_id and all of the other fields the user fills out to enter into a table (this part, I know how to do).

I know how to use php to place data from a form into a database..BUT, My question is, how do I pass a variable (job_id) between the original job description page, to the jobsubmit.html page, and into a form field?? Is it even possible?

thanks in advance,
-l.

Any variable submitted by a form is accessible to php on the next page via the name used on the form for that item.

Ex: <input name="job_id" value="123">

In the next page you can call that var in php by using the request variable (http://www.php.net/manual/en/language.variables.external.php)

echo $_REQUEST;

Member Avatar for Zagga

Hi lwaterfo,

You will also need to save your pages as .php pages to be able to use PHP functions in them (jobsubmit.php instead of jobsubmit.html).


Zagga

thanks mazeroth and zagga! I'll try that out...

hi,
well, I just tried it and it didn't work for me.
here is my php code:

<?php
echo $_REQUEST['job_id'];
?>

and here is my html code:

<form action="postid.php" method="POST">
<p>
  <input name="job_id" type="text" value="123" />
</p>
<p>
  <input name="Submit" type ="button" value="Submit" />
  </form>

got any ideas??

Member Avatar for Zagga

Hi again,

In the php code, try replacing ($_REQUEST) with ($_POST), and in the form replace (method="POST") with (method="post").


Hope this helps.
Zagga

thx zagga, but it still doesn't work! I am so frustrated..
Maybe its my browser..I am using safari version 5.0
I'll keep playing around with the code...

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.