i am having a small problem. I am having some problem getting variables from the first form into another form to be processed. in other words i am processing the same data i got from the first form twice but i want a break between the two blocks that processes the information. here is my code below

<?php

function form()
 {

$hostname = "localhost";
$username = "root";
$password = "hayden";
$database = "ecng3020";


$courses_options = "";
$con = mysql_connect("$hostname","$username","$password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  mysql_select_db("$database", $con);
  
  $courses_options .= "<option value=\"NULL\">Course :</option>\n";
	$try="Select course_code,course_name FROM courses";
   $rsrcResult = mysql_query($try);
$courses_options .= "<select name=coursecode_1[]  size=4 multiple>";
   while($row = mysql_fetch_row($rsrcResult)) {
     
		$strA=$row[0];
		$strB=$row[1];
	 
	 
	

	 $courses_options .= "<option value=\"$strA\">$strB</option>\n";
   }

   $courses_options .= "</select>";


 echo <<<EOB
 <form method=post action=''>
 <p>$courses_options</p>
 
 
  <p>
  	<input type="submit" name="submit" value="Submit" />
		<input type="reset" name="Reset" value="Cancel" />
  </p>
</form>
EOB;

}
?>
<?php
@session_start();



$po=1;

if ($po==0)
{

}
else
{
form();
if ($_POST['submit'] == 'Submit')
{

$hostname = "localhost";
$username = "root";
$password = "hayden";
$database = "ecng3020";

	$con = mysql_connect("$hostname","$username","$password");
	if (!$con)
 	 {
  		die('Could not connect: ' . mysql_error());
  	}

	mysql_select_db("$database", $con);
					
					$id=$_SESSION['username'];
					@$code= $_POST['coursecode_1'];
					$_SESSION['courses']=$code;
					
					print_r($_SESSION['courses']);
					
					
					if( is_array($code))
					{
							//$sum= array();
							
						while (list ($key, $val) = each ($code)) 
						{
							//echo "$val ";  //val contains the course code
							// 
							//$_SESSION['courses']=$val;
							$q="SELECT sum(credits) FROM courses WHERE course_code='$val'";
							if ($result_2=mysql_query($q))
											
							$row = mysql_fetch_row($result_2);
							$first=$row[0];
							$sum= $sum+$first;	
							//echo "$sum";
							$_SESSION['credit_total'] = $sum;
							
							
							
							$sql= "SELECT  * FROM rules WHERE type='prerequisite' ";
								//$result=mysql_query($sql);
							 if ($result=mysql_query($sql))
								//echo '<p>nice</p>';
								//else
								//echo 'good shit';
					 
					//$row = mysql_fetch_row($result)
					
						
							while ( $row_3 = mysql_fetch_assoc($result))
							{
									extract($row_3);
									//echo $parameters;
					
							
							 
								$course= explode (",",$parameters);
								//echo $course[1];
							
									if ($course[1]==$val)
									{
										$sql_1=" SELECT  * FROM student_course WHERE course_code ='$course[0]' and id_no ='$id'";
										if ($result_1=mysql_query($sql_1))
										//	echo '<p>nice1</p>';
											//else
											//echo 'good shit';
						
											if ($row_1 = mysql_fetch_assoc($result_1))
													extract($row_1);
													//echo $course_status;
												if($row_1[0]=='pass')
												{
												echo"<h3><p>you have passed $course[1]</p></h3>";
												//header("location:page.html");
						
													//echo " $row[0]";
												}
												else 
												{
						 
													$sql_2= "SELECT  error_message FROM rules Where parameters= '$parameters'";
					
													if ($result_2=mysql_query($sql_2))
													//echo '<p>nice12</p>';
													//else
													//echo 'good shit';
						
													$row_2 = mysql_fetch_row($result_2);
													$count= mysql_num_rows($result_2);
													$_SESSION['count']=$count;
													$message=$row_2[0];
													echo "<h3><p>$message</p></h3>";
					
													//echo'you have to do over Communication Systems 1 ';
													//exit();
												}
															//echo 'almost there';
								
									//break;
									}
									// need to put in a statement where it says there are no prerequsite for the courses
							//echo"$row[0] $row[1] $row[2]";
							
							}
							// this is the loop 
						//echo $_SESSION['courses'];
					
							}
					 
							//button();
						}
						//prerequsite();	
						
						@$total=$_SESSION['credit_total'];
						
						$sq=" select * from rules WHERE type='semester_load' ";
								$res=mysql_query($sq);
								$msg=mysql_fetch_assoc($res);
								extract($msg);
								
							if ($sum>$parameters)
							{
								
								echo "<h3><p>$error_message</p></h3>";
								
							}	
							else
							{
								echo "<h3><p>You can attampt this Semester Load</p></h3>";
								 
							}
							if($_SESSION[count])
								{
									echo"<p>&nbsp;</p>";
									
									echo " Please Note that you have found to be infringing on one or more rules of the Department <br>";
									
									
				
									//echo "the amount of error messages are $_SESSION[count]";
								}	
								button();
						}
					}
	
	$code1=array();
	@$code1= $_SESSION['courses'];
	print_r($code1);
	echo  $_SESSION['courses'];
	echo "<br> <br> Post: <pre>";
	print_r($_POST);
	echo "</pre>";
					
	if ($_POST['submit1'] == 'Continue')
	{
			//$store=array();
			echo $_POST['ID'];
			print_r($code1);
			
			echo "here!!!";
			
			//print_r($code1);
			
			//print_r($_SESSION['courses']);
			//print_r($_SESSION);
			
			//echo "here!!!";
			
			
			if( is_array($code1))
			{
				echo "The Course(s) that you have selected are:<br> ";
				echo"<p>&nbsp;</p>";
					//$sum= array();
				while (list ($key, $val1) = each ($code1)) 
				{
					//$store[]="$val1";
					//echo $val1;
					$c="SELECT * FROM courses WHERE course_code= '$val1'";
					$r=mysql_query($c);
					$m=mysql_fetch_assoc($r);
					extract($m);
					echo "$course_name<br>";
					
					//echo $store[0];
					//echo $store[1];
					//print_r($store);
					//$_SESSION['store']=$store;
				}
				/*
				if($_SESSION[count])
				{
					echo"<p>&nbsp;</p>";
					
					echo " Please Note that you have found to be infringing on one or more rules of the Department <br>";
					
					

					//echo "the amount of error messages are $_SESSION[count]";
				}
				*/
			}
			echo"<p>&nbsp;</p>";
			$h=$_SESSION['current_total'];
			$final=$_SESSION['credit_total']+12;
			echo " Your Forcasted credit total $final";
			//echo "$_SESSION[courses]";
	}
	
	

function button()
{
echo <<<EOB
	
	<form action="{$_SERVER['PHP_SELF']}" method="post">
		
				//<input type="hidden" name="ID" value="{$_POST[coursecode_1]}" />

		<input type="submit" name="submit1" value="Continue" />
		<input type="submit" name="submit1" value="Cancel" />
	
	</form>
	
EOB;
}



?>

as u can see lines 239=271 are not executing for some reason can some one help me out here please

ok i have done some work on this code and found out that when i print out the first form it works ok and also in processing the data it also work ok. i have found a problem, i have set a session variable and this variable contains information however when the second form is printed out and the continue button is pressed the session variable is some how cleared. can some one explain why this is happening. and maybe offer a solution as to how to keep the value in the session variable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.