Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Basic multi-form database upload question



11:06 pm on Jul 21, 2007 (gmt 0)

5+ Year Member

I'm learning php and mysql. As an exercise, and in order to create something I need, I am building a page builder.

So how would the following process take place best with php and mysql?

I have a series of form pages containing inputs for collecting information that will be used to build a 'breeder listing' page.

Once the user has filled in each page and submits the third page, he will be sent to a review page showing how his listing page will look except with an 'Upload' button and an 'edit' button, allowing him to review his page.

This will then create a new page.

If I understood how this process is done, I can look up all the details, but I'm confused on the process.


4:52 am on Jul 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

So how would the following process take place best with php and mysql?

If the visitors do have Username and password, let them login and save whatever actions they make into the database. Query the database for simple displaying, query the database to add new rows or update.

If they don't have a username, provide session values, and follow the same process of adding, updating and displaying data from the database.

If this doesn't answer your question, you need to be a little bit more specific of what you exactly need.



7:22 pm on Jul 22, 2007 (gmt 0)

5+ Year Member

Let me summarize how I think things work, feel free to correct.

A form is created and handled in stages. First, it is created. After submission it is re-created with any error messages or sent to the next step of displaying the information then uploading it.

Do you have a normal html header and put all the php in the body?


7:27 am on Jul 23, 2007 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Temporarily form values can be stored in a session [php.net] to retain the information so that if the form needs to be edited for whatever reason it can be without having to rekey the info again. Once the user is sure that they want to submit the data, the information can be placed in the database. Refer to the mysql documentation [php.net] for related functions.

good luck


7:58 am on Jul 23, 2007 (gmt 0)

5+ Year Member

I think what I'm struggling with is the basic design philosophy. From the simple examples I've looked at, it seems I should build a single page with several functions.

The first function would run writing the first form. A second function would run if a hidden form input in the first form is found in $_POST, checking the inputs of the first form.

Somehow, a third function would re-write a second for, a forth function would check that, and so on until the end where the last function would use the form inputs to build a 'review' page where the user could either go back for corrections or upload the form into a database where it would feed a page.

Is this correct? I've experimented using variables to keep track of what functions has run, but I must misunderstand php variables because it wasn't working...

I'm also missing a number of other design techniques that are hard to figure out by reading php documentation but if I understand the basic mechanisms I could mush more easily know what to look for.

I've only found one good example on onlamp.com It confuses me though. I tryed the code copy / past but I think my local server must have different setting or the code is not complete because it doesn't work like it does on their page.

With sessions would I use multiple pages maintaining inputs within the session?

I wish I had a good example. Learning html, css, and JavaScript is some much easier to find example for - the trouble with them is finding good ones.


8:10 am on Jul 23, 2007 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 10+ Year Member

I think you are making this more complicated than it should be. Try starting as basic as you can get and then add onto what you have built already. Some additional resources that you may find useful:
Dealing with Forms [php.net]
Variables from outside PHP [us.php.net]


11:03 am on Jul 23, 2007 (gmt 0)

5+ Year Member

I think your absolutely right eelixduppy, I came to that conclusion laying in bed a few hours ago.

I need to do some simple experimentation.


4:38 am on Jul 24, 2007 (gmt 0)

5+ Year Member

Ok, I've made some progress and have a couple specific questions.

1. How do I stop the form process when an error condition is found?

2. What is a good way to arrange things so that error appear under each input?

Here is the code. My current problem is that the page processes before the error displays.

// Verify something has been inputed
function _input_filled($input)
if (strlen(trim($input)) <= 5) return 1;
else return 0;

print "<form name='form1' id='form1' enctype='multipart/form-data'
action = 'breeder-list-2.php' method = 'post' />";
print "<input type='text' name='name' size='20' value='' />";
print "<input type='submit' name='submit' value='submit' />";
print "<input type='hidden' name='_submit_check' value='1' />";
print "</form>";

if (array_key_exists('_submit_check',$_POST))
if (_input_filled($_POST['name']))
print "Input Nam";



Featured Threads

Hot Threads This Week

Hot Threads This Month