Hi,

I am trying to build a multipage php form using mysql as the backend much like the ones in monster.com.

First page with the personal details
Second page with educational details
Third page with work experience details

Can some one please give me a thread or a link or a source for me to get started.

Thanks much for the help.

Recommended Answers

All 4 Replies

Basically, how it works is you use a form on each page.:
page1.php

<form method="post" action="page2.php">
First Name:<input type="text" name="first_name" /><br>
Last Name:<input type="text" name="last_name"  /><br>
<input type="submit" name="submit" />
</form>

Then in page 2, you echo the variables from page 1 into hidden fields in the form for use on page 3:
page2.php

<?php
$fname=$_POST['first_name'];
$lname=$_POST['last_name'];
?>
<html>
<head></head>
<body>
<form method="post" action="page3.php">
<input type="hidden" name="first_name" value="<?php echo $fname;?>" />
<input type="hidden" name="last_name" value="<?php echo $lname;?>" />
Education:<input type="text" name="education" /><br>
School:<input type="text" name="school" /><br>
<input type="submit" name="submit" />
</form>
</body>
</html>

The same goes for page 3:
page3.php

<?php
$fname=$_POST['first_name'];
$lname=$_POST['last_name'];
$education=$_POST['education'];
$school=$_POST['school'];
?>
<html>
<head></head>
<body>
<form method="post" action="page4.php">
<input type="hidden" name="first_name" value="<?php echo $fname;?>" />
<input type="hidden" name="last_name" value="<?php echo $lname;?>" />
<input type="hidden" name="education" value="<?php echo $education;?>" />
<input type="hidden" name="school" value="<?php echo $school;?>" />
Experience:<input type="text" name="experience" /><br>
<input type="submit" name="submit" />
</form>
</body>
</html>

Now, all the variables from all 3 pages are posted to page 4.
Hope this helps

i use a session array to hold the values and at the very end pull the data from the array and process it into a database.

I would go with sessions too . They are a better and neat way of doing this.

To start a session

session_start();

To write variables into session

$_SESSION[variable_name] = variable_value;

To end a session

session_destroy();

remember to use session_start() at the top of every page that you want your session variables to be readable :)

Yes, the session would work. Cookies would work as well. The code I posted was meant to build a basic understanding of passing variables from page to page.

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.