Creating a multi-step process with mysql and php

Posted by Paul Atkins on Stack Overflow See other posts from Stack Overflow or by Paul Atkins
Published on 2010-12-23T01:25:50Z Indexed on 2010/12/23 1:54 UTC
Read the original article Hit count: 606

Filed under:
|

Hi,

I am working on a script which allows users to create a stepped process.

The steps will consist of sending visitors to urls where they will fill out a form then be directed to the next step the user has created. Each user can create as many steps as they wish and the url for each step will be unique.

I am not sure if I am doing this in the correct/most efficient way so I have a few questions about this. Before I begin here is a simple version of my table structure:

step_id     user_id       step_url                   step_order
  1           1       example.com?step=1              1
  2           2      test.com?step=1                  1
  3           1       example.com?step=3              2

A visitor will be directed to step_url: example.com?step=1 by user_id: 1

On this page there will be a form which contains a hidden field with the value of the step_id like this:

<input type="hidden" name="step_id" value="1">

Once the visitor has filled out this form it will be processed by my script at a url similar to: http://mysite.com/form-process.php

Once the form has been submitted I then need to direct the visitor to the next step my user has created.

I would currently do this using code similar to this:

SELECT step_url FROM table WHERE step_order='$current_step_order'+1

Here are my questions about this:

  1. Is this the best most efficient way to accomplish this? Or is there a better way?

  2. As the step_id column is auto increment...how would I increment the order column by 1 each time a user inserts a new step?

Thanks for taking the time to read this.

Paul

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql