...

View Full Version : Online Quote Sessions



james182
11-29-2006, 03:07 AM
Whats wrong with my code??

its not storing the data for more then 1 step.
on step 1: put in project, and it show on step 2 but not step 3, only step 2 shows up on step 3.


<?
session_start();// This connects to the existing session
/*
session_register("project");// Create a session variable called first_name
session_register("company");
session_register("website");
*/
$_SESSION['project'] = $_POST['project'];
$_SESSION['company'] = $_POST['company'];
$_SESSION['website'] = $_POST['website'];

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Quotes</title>
<link href="nb2.css" rel="stylesheet" type="text/css" />
</head>

<body>

Welcome to online website Quote System.<br />
<a href="index2.php?cmd=delete" target="_self">Destroy session</a> | <a href="index2.php?step=1" target="_self">Start Quote</a><br /><br />

Project: <? echo $_SESSION['project']; ?><br><br />
Company: <? echo $_SESSION['company']; ?><br><br />

<hr />
<?

if($_GET["step"]=="1"){
echo 'step one<br><br>';
?>

<form method="post" id="main-form" name="quicknote" action="index2.php?step=2" enctype="multipart/form-data">

<legend>Creative Brief</legend>
Project <input name="project" type="text" size="25" />
<p class="submit_field">
<input type="image" src="images/next_button.png" value="Submit" name="Submitform" alt="Submit Form" />
</p>
</form>
<?
if($_POST['Submit']){
$project = $_POST['project'];

}
?>

<? } ?>

<?
if($_GET["step"]=="2"){
echo "step 2 <br><br>";
?>
Project: <? echo $_SESSION['project']; ?><br><br />
<form method="post" id="main-form" name="quicknote" action="index2.php?step=3" enctype="multipart/form-data">
<legend>Creative Brief 2</legend>
Company: <input name="company" type="text" size="25" />
<p class="submit_field">
<input type="image" src="images/next_button.png" value="Submit" name="Submitform" alt="Submit Form" />
</p>
</form>
<?
if($_POST['Submit']){
$project = ($_SESSION['project']);
$company = ($_SESSION['company']);
//$_SESSION['company'][$company]=$_POST['company'];
}
?>

<? } ?>

<?
if($_GET["step"]=="3"){
echo "step 3 <br><br>";
?>
<legend>Details</legend>
Project: <?=$_SESSION['project']?><bR />
Company: <?=$_SESSION['company']?><br />

<? } ?>

<?
if($_GET["step"]=="4"){
echo "step 4";
?>
//nothing yet.

<? } ?>

<?
if($_GET["cmd"]=="delete"){
echo "Destroy";
?>
<? session_destroy(); ?>

<? } ?>

</body>
</html>

gunman
11-29-2006, 10:05 AM
Check out that code it's a little bit modified


<?
session_start();// This connects to the existing session
/*
session_register("project");// Create a session variable called first_name
session_register("company");
session_register("website");
*/


$_SESSION['project'] = (!isset($_SESSION['project'])?$_POST['project']:$_SESSION['project']);
$_SESSION['company'] = (!isset($_SESSION['company'])?$_POST['company']:$_SESSION['company']);
$_SESSION['website'] = (!isset($_SESSION['website'])?$_POST['website']:$_SESSION['website']);

//var_dump($_SESSION);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Quotes</title>
<link href="nb2.css" rel="stylesheet" type="text/css" />
</head>

<body>

Welcome to online website Quote System.<br />
<a href="<?=$_SERVER['PHP_SELF']?>?cmd=delete" target="_self">Destroy session</a> | <a href="<?=$_SERVER['PHP_SELF']?>?step=1" target="_self">Start Quote</a><br /><br />

Project: <? echo $_SESSION['project']; ?><br><br />
Company: <? echo $_SESSION['company']; ?><br><br />

<hr />
<?

if($_GET["step"]=="1"){
echo 'step one<br><br>';
?>

<form method="post" id="main-form" name="quicknote" action="<?=$_SERVER['PHP_SELF']?>?step=2" enctype="multipart/form-data">

<legend>Creative Brief</legend>
Project <input name="project" type="text" size="25" />
<p class="submit_field">
<input type="image" src="images/next_button.png" value="Submit" name="Submitform" alt="Submit Form" />
</p>
</form>
<?
if($_POST['Submit']){
$project = $_POST['project'];

}
?>

<? } ?>

<?
if($_GET["step"]=="2"){
echo "step 2 <br><br>";
?>
Project: <? echo $_SESSION['project']; ?><br><br />
<form method="post" id="main-form" name="quicknote" action="<?=$_SERVER['PHP_SELF']?>?step=3" enctype="multipart/form-data">
<legend>Creative Brief 2</legend>
Company: <input name="company" type="text" size="25" />
<p class="submit_field">
<input type="image" src="images/next_button.png" value="Submit" name="Submitform" alt="Submit Form" />
</p>
</form>
<?
if($_POST['Submit']){
//$project = ($_SESSION['project']);
$company = ($_POST['company']);
//$_SESSION['company'][$company]=$_POST['company'];
}
?>

<? } ?>

<?
if($_GET["step"]=="3"){
echo "step 3 <br><br>";
?>
<legend>Details</legend>
Project: <?=$_SESSION['project']?><bR />
Company: <?=$_SESSION['company']?><br />

<? } ?>

<?
if($_GET["step"]=="4"){
echo "step 4";
?>
//nothing yet.

<? } ?>

<?
if($_GET["cmd"]=="delete"){
echo "Destroy";
?>
<? session_destroy(); ?>

<? } ?>

</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum