Page 1 of 1

Doing something wrong .. new fresh eyes..

Posted: Thu Nov 06, 2003 10:36 pm
by filch
Wonder if someone could look at this and see if they can spot where I am messing this up. I am trying to construct a script that loads itself in successive steps:

Step one: choose the type of 'Special'
Step two: choose a product for the special
Step three: add the content of the special and save it to the DB

I am using DreamWeaver here so there will be some DW specific coding as well as my own.

I will only post the relavent bits of code. The first bit is the container page that calls various includes to accomplich the steps above.

Code: Select all

<?php
			
			if (!$_POST&#1111;'type']) &#123;
				include($_SERVER&#1111;'DOCUMENT_ROOT']."/assets/includes/chooseType.php");
			&#125; elseif ($_POST&#1111;'type'] == "product") &#123;
				print "The type of special is: " . $_POST&#1111;'type'] . "<br>";			
				include($_SERVER&#1111;'DOCUMENT_ROOT']."/assets/includes/chooseProduct.php");
			&#125; elseif (($_POST&#1111;'type'] == "product") && ($_POST&#1111;'select'])) &#123;
				print "The product id is: " . $_POST&#1111;'select'] . "<br>";
				print "Product Selected - Load addProductSpecials.php";
				include($_SERVER&#1111;'DOCUMENT_ROOT']."/assets/includes/addProductSpecial.php");
			&#125; elseif ($_POST&#1111;'type'] == "general") &#123;
				include($_SERVER&#1111;'DOCUMENT_ROOT']."/assets/includes/addGeneralSpecial.php");
			&#125;   
			?>
The next two bits are the first two includes. I won't submit the third include as the code I have written never allows it to be loaded ... which is what I am trying to solve.

This include simply presents the user a choice of a 'Prioduct Special' or a 'General Special':

Code: Select all

<form ACTION="<?php $_SERVER&#1111;'PHP_SELF'] ?>" METHOD="post" NAME="chooseType" ID="chooseType">
            <table WIDTH="50%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
                <tr><td CLASS="darkTBLHdr">Choose the type of special you wish to create:</td>
                    <td><p><label><input TYPE="radio" NAME="type" VALUE="product">Product</label><br>
                        <label><input TYPE="radio" NAME="type" VALUE="general">General</label>
                        <br></p></td></tr><tr><td align="left"><a HREF="/vsadmin/adminSpecials.php">Back To Main</a></td><td><input TYPE="submit" NAME="Submit" VALUE="Next"></td></tr></table></form>
The code above works fine and the value of $_POST['type'] is correctly passed back to the first bit of code and it correctly calls the second include ... which follows:

Code: Select all

<?php require_once($_SERVER&#1111;'DOCUMENT_ROOT'] . '/Connections/rr.php'); ?>
<?php
mysql_select_db($database_rr, $rr);
$query_rsSpecials = "SELECT products.pID, products.pName, products.pImage, products.pPrice, specials.id, specials.type, specials.specialPrice, specials.idname, specials.head, specials.info_one, specials.info_two, specials.buttons, specials.s_date, specials.e_date FROM products, specials";
$rsSpecials = mysql_query($query_rsSpecials, $rr) or die(mysql_error());
$row_rsSpecials = mysql_fetch_assoc($rsSpecials);
$totalRows_rsSpecials = mysql_num_rows($rsSpecials);
?>
<?php echo $_SERVER&#1111;'PHP_SELF']; ?>
<form ACTION=<?php  echo $_SERVER&#1111;'PHP_SELF']; ?>?pID=<?php echo $_POST&#1111;'select']; ?> METHOD="post" NAME="chooseProduct">
				<table WIDTH="50%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
				<tr><td HEIGHT="31" CLASS="darkTBLHdr">Choose the product you wish to use for the special:</td>
				<td>
				<select NAME="select" ID="select">
				    <?php
do &#123;  
?>
				    <option value="<?php echo $row_rsSpecials&#1111;'pID']?>"<?php if (!(strcmp($row_rsSpecials&#1111;'pID'], $row_rsSpecials&#1111;'pName']))) &#123;echo "SELECTED";&#125; ?>><?php echo $row_rsSpecials&#1111;'pName']?></option>
				    <?php
&#125; while ($row_rsSpecials = mysql_fetch_assoc($rsSpecials));
  $rows = mysql_num_rows($rsSpecials);
  if($rows > 0) &#123;
      mysql_data_seek($rsSpecials, 0);
	  $row_rsSpecials = mysql_fetch_assoc($rsSpecials);
  &#125;
?>
				</select>
</td></tr><tr><td><input TYPE="submit" NAME="Submit" VALUE="Next">
        <input NAME="type" TYPE="hidden" ID="type" VALUE="<?php echo $_POST&#1111;'type'] ?>">
        <input NAME="pID" TYPE="hidden" ID="pID" VALUE="<?php echo $_POST&#1111;'pID'] ?>"></td>
    <td><?php echo $_POST&#1111;'type']; ?> <br> <?php echo $_POST&#1111;'select']; ?></td>
</tr></table>
</form>

<?php
mysql_free_result($rsSpecials);
?>
This is where I am having an issue. Even though I am able to echo the value of $_POST['select'], the first script does not seem to recognize that it has been set and thereby load the final include. In fact, although I am able to print the select value, my script refuses to print a value for $_POST['select'] in the form action.

I am sure by this time my scripts are full of error as I have been trying to solve this for a bit now. I don't think at this point I could see the errors if I fell on them. Might just have to start from scratch.

Anyway, I would appreciate it if someone sees the error of my ways ... that they would let me know and sorry for the long ass post ;-)

Dave