template for multistage form

<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);

/*
TITLE OF THE SCRIPT
-------------------
Description of the script.
*/

session_start();

/* **********************************
INCLUDES SECTION BEGIN
*/

$docRoot = $_SERVER["DOCUMENT_ROOT"];

// I know the comments here are vague and confusing to someone
// who is unfamiliar with the system. It's okay because the
// people who should understand it will if they keep trying.
// And, the people who shouldn't understand it are not going
// to get my help in doing so.

// Include the file for functions related to user management.
// It's been omitted here for security.

// When you need database access you'll need to include the file
// which connects. HOWEVER, don't include it here. Include it
// before every statement which accesses the database.
// Note that the the file which contains the functions related
// to user management sets the ping-pong variable. If that
// file is not included then you will have to set the ping-pong
// variable.

require_once("$docRoot/web/includes/header_footer.php");

/*
INCLUDES SECTION END
*************************************
*/

// User must be logged in and be someone special.
if (!user_isloggedin() || !user_type_cookieIsSet()) {
  form_destroy();
  $host = $_SERVER['HTTP_HOST'];
  header("Location: http://{$host}/web/login.php");
  exit;
}
if ($_COOKIE['user_type'] != 1) {
  form_destroy();
  die('Script aborted #3098. -Programmer.');
}

// Cancel if requested.
if (isset($_POST['cancel'])) {
  form_destroy();
  $host = $_SERVER['HTTP_HOST'];
  $uri = $_SERVER['PHP_SELF'];
  header("Location: http://$host$uri");
  exit;
}

if (isSet($_SESSION['PREPENDFORTHISSCRIPT_mode'])) {
  $mode = $_SESSION['PREPENDFORTHISSCRIPT_mode'];
} else {
  $mode = 'stageOne';
}


if ($mode == 'stageOne') {





  $_SESSION['PREPENDFORTHISSCRIPT_mode'] = 'process the form';
} elseif ($mode == 'process the form') {
  processTheForm();





  $_SESSION['PREPENDFORTHISSCRIPT_mode'] = 'delete or not';
} elseif ($mode == 'delete or not') {





  form_destroy();
} else {
  form_destroy();
  die('The script died for reason # 294875654. -Programmer.');
}




/* **************
FUNCTIONS SECTION:
*/
function form_destroy() {
  $_SESSION['PREPENDFORTHISSCRIPT_mode'] = 'stageOne';
  $_SESSION['PREPENDFORTHISSCRIPT_submitToken'] = "";

  return;
}




function explain_the_script() {


  return;
}




function () {


  return;
}




function () {


  return;
}

?>
Advertisements

About samehramzylabib

See About on https://samehramzylabib.wordpress.com
This entry was posted in Coding, PHP Script Writing and tagged , , . Bookmark the permalink.

Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s