Showing Results of a form Submit into a Primarycontent div in php

Hello, working on a school project, I am 95% finished: Objective - to open a submitted form via a Save button into the same primary content div area that the parent form was in.

Main Page

IT-5334: Wendy Combs
<?php include "header.php"; ?>
<?php include "topmenu.php"; ?>
<?php if (isset($_GET['menukey'])) { $menukey = $_GET['menukey']; } else { $menukey = 0; } switch ($menukey) { case 1: include "primarycontent.php"; break; case 2: include "aboutme.php"; break; case 3: include "WhatIDo.php"; break; case 4: include "ContactMe.php"; break; case 5: include "AdvisorsEdit.php"; break; default: // case else include "primarycontent.php"; break;
	    }

?>

		</div>
	</div>
	<div id="secondaryContent">
		<?php
		include "secondarycontent.php"
		?>
	</div>
	<div class="clear"></div>
</div>
<div id="footer">
	<?php
	include "footer.php";
	?>

</div>

Form Page

<?php $AdvisorID = "87" ; $Salutation = "Mr." ; $FirstName = "Thomas" ; $LastName = "Anderson" ; ?>
<tr>	
  <td align=right valign=top nowrap><font face=verdana size=2>&nbsp;</font></td>
  <td nowrap>
	<table width="100%" cellspacing="0" cellpadding="0" border="0">
	 <tr>	
  	  <td><input class="txtmedium" type=text maxlength="30" value="" Name="txtPhone">&nbsp;&nbsp;</td>
  	  <td><input class="txtmedium" type=text maxlength="30" value="" Name="txtmobile">&nbsp;&nbsp;</td>
  	  <td><input class="txtmedium" type=text maxlength="30" value="" Name="txtFax"></td>
	  <td width=97% nowrap>&nbsp;</td>
	 </tr>
	 <tr class="aligntop">	
  	  <td>Phone</td>
  	  <td>Mobile</td>
  	  <td>Fax</td>
	  <td>&nbsp;</td>
	 </tr>
	 <tr class="aligntop"><td colspan=4>&nbsp;</td></tr>
	</table></td>
</tr>

<tr>	
  <td align=right><font face=verdana size=2>EMail:&nbsp;</font></td>
  <td> <input class="txtwide" type=text maxlength="250" value="" Name="txtEMail"></td>
</tr>

<tr>
  <td align="right" Nowrap><font face=verdana size=2>Major:&nbsp;</font></td>
  <td>
    <SELECT NAME="selMajor" Size="1">
	<OPTION VALUE="0" SELECTED>Select the Major for this Advisor . . .</option>
	<OPTION VALUE="Aviation Maintenance Technology">AMT - Aviation Maintenance Technology</option>
	<OPTION VALUE="Business Information Systems">BIS - Business Information Systems</option>
	<OPTION VALUE="Biomedical Electronics Engineering Technology">BMET - Biomedical Electronics Engineering Technology</option>
	<OPTION VALUE="Civil Engineering Technology">CET - Civil Engineering Technology</option>
	<OPTION VALUE="Chemical Technology">CMT - Chemical Technology</option>
	<OPTION VALUE="Computer Network Engineering Technology">CNET - Computer Network Engineering Technology</option>
	<OPTION VALUE="Computer Programming and Database Management">CPDM - Computer Programming and Database Management</option>
	<OPTION VALUE="Electronics Engineering Technology">EET - Electronics Engineering Technology</option>
	<OPTION VALUE="Electro-Mechanical Engineering Technology">EMET - Electro-Mechanical Engineering Technology</option>
	<OPTION VALUE="Environmental Engineering Technology">EVET - Environmental Engineering Technology</option>
	<OPTION VALUE="Industrial Design Technology">IDT - Industrial Design Technology</option>
	<OPTION VALUE="Laser Electro Optics Engineering Technology">LEOT - Laser Electro Optics Engineering Technology</option>
	<OPTION VALUE="Mechanical Engineering Technology">MET - Mechanical Engineering Technology</option>
	<OPTION VALUE="Multimedia Information Design">MID - Multimedia Information Design</option>
	<OPTION VALUE="Network Administration Technology">NETAD - Network Administration Technology</option>
	<OPTION VALUE="Software Engineering Technology">SET - Software Engineering Technology</option>
    </SELECT></td>
</tr>
<tr>	
  <td align=right><font face=verdana size=2>Will Attend Meeting:&nbsp;</font></td>
  <td class="radiobtn">  <input type="radio" name="rdomeeting" value="Yes" /> Yes&nbsp;&nbsp;&nbsp;
	<input type="radio" name="rdomeeting" value="No" /> No&nbsp;&nbsp;&nbsp;
	<input type="radio" name="rdomeeting" value="Unknown" /> Unknown</td>
</tr>
<tr>
  <td align="right" valign="top" nowrap><font face=verdana size=2>Advisor Constituency:&nbsp;</font></td>
  <td valign="top">
    <div id="chklist">
	<table cellspacing="6" cellpadding="3" border="0">
	  <tr><td><font color=black>Select all Constituency Groups that apply:</font></td></tr>
	  <tr><td><b><hr size=0 color=silver noshade></b></td></tr>
	  <tr><td><input value="1st Year Student" type="checkbox" name="chkCon"  />&nbsp;1st Year Student</font></td></tr>
	  <tr><td><input value="2nd Year Student" type="checkbox" name="chkCon"  />&nbsp;2nd Year Student</font></td></tr>
	  <tr><td><input value="4 Year College Professor" type="checkbox" name="chkCon"  />&nbsp;4 Year College Professor</font></td></tr>
	  <tr><td><input value="Adjunct Faculty" type="checkbox" name="chkCon"  />&nbsp;Adjunct Faculty</font></td></tr>
	  <tr><td><input value="Alumni/Graduate" type="checkbox" name="chkCon"  />&nbsp;Alumni/Graduate</font></td></tr>
	  <tr><td><input value="High School Teacher" type="checkbox" name="chkCon"  />&nbsp;High School Teacher</font></td></tr>
	  <tr><td><input value="Industry Representative" type="checkbox" name="chkCon"  />&nbsp;Industry Representative</font></td></tr>
	</table>
    </div>
  </td>
</tr>

<tr>	
  <td align=right valign=top><font face=verdana size=2>Notes:&nbsp;</font></td>
  <td><textarea name="txtAreaNotes" wrap="true"></textarea></td>
</tr>

<tr><td colspan=2 height="20"><hr size=0 color=silver noshade></td></tr>
<tr><td colspan=2 align="center" nowrap>
	<input type="submit" name="action" value="Save" formtarget="_parent">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<input type="submit" name="action" value="Cancel">
	<input type="hidden" name="AdvisorID" value="87"</td>
</tr>
</table>

Results Page:

<?php switch($_POST['action']) { case "Cancel": header("Location: Index.php"); --------------------> this works, brings user back to original page break; case "Save":---------------------> does pull up page in blank webpage, but does not work in primarycontent are, not sure how to code $AdvisorID = $_REQUEST['AdvisorID']; break; default: ("Location: AdvisorsEdit.php"); } $today = date("F j, Y, g:i A"); // Format: March 10, 2001, 5:16 PM /* Date Format Samples... $today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm $today = date("m.d.y"); // 03.10.01 $today = date("j, n, Y"); // 10, 3, 2001 $today = date("Ymd"); // 20010310 $today = date('h-i-s, j-m-y, it is w Day'); // 05-16-18, 10-03-01, 1631 1618 6 Satpm01 $today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // it is the 10th day. $today = date("D M j G:i:s T Y"); // Sat Mar 10 17:16:18 MST 2001 $today = date('H:m:s \m \i\s\ \m\o\n\t\h'); // 17:03:18 m is month $today = date("H:i:s"); // 17:16:18 */ $Salutation = $_REQUEST['txtSalutation']; $FirstName = $_REQUEST['txtFirstName']; $LastName = $_REQUEST['txtLastName']; // Validate the notation of meeting attendance if (isset($_REQUEST['rdomeeting'])) { $meetingID = $_REQUEST['rdomeeting']; if ($meetingID == 1) { echo "$meetingID"; } elseif ($meetingID == 2) { echo "$meetingID"; } elseif ($meetingID == 3) { echo "$meetingID"; } } else { // Meeting Not Set $meetingID = NULL; echo "Meeting Designation Not Set!
"; } if (!empty($_REQUEST['chkCon'])) { $ChkCon = $_REQUEST['chkCon']; } else { $ChkCon = 0; } $Address1 = $_REQUEST['txtAddress1']; $Address2 = $_REQUEST['txtAddress2']; $City = $_REQUEST['txtCity']; $State = $_REQUEST['txtState']; $Zip = $_REQUEST['txtZipCode']; $Company = $_REQUEST['txtCompanyName']; $Title = $_REQUEST['txtTitle']; $Department = $_REQUEST['txtDepartment']; $HomeNo = $_REQUEST['txtPhone']; $CellNo = $_REQUEST['txtmobile']; $FaxNo = $_REQUEST['txtFax']; $Email = $_REQUEST['txtEMail']; $Major = $_REQUEST['selMajor']; $Notes = $_REQUEST['txtAreaNotes']; ?>
Advisor: 
       
Salutation First Name Last Name  
Job Title: 
Company Name: 
Department: 
Address1: 
Address2: 
 
       
City State Zip Code  
<tr>	
<td>Department</td>
<td><?php echo "$Department"; ?></td>
</tr>
   	<tr>
      	<td>Home Phone</td>
     	<td><?php echo "$HomeNo"; ?></td>
   </tr>
   <tr>
        <td>Cell Phone</td>
        <td><?php echo "$CellNo"; ?></td>
  </tr>
  <tr>
       <td>Fax</td>
       <td><?php echo "$FaxNo"; ?></td>
  </tr>

<tr>
  <td>EMail</td>
  <td><?php echo "$Email"; ?></td>
</tr>
<tr>
  <td>Major</td>
  <td><?php echo "$Major"; ?></td>
</tr>
<tr>
  <td>Will Attend Meeting</td>
  <td><?php echo "$meetingID"; ?></td>
</tr>
<tr>
  <td>Advisor Constituency</font></td>
  <td><?php echo "$ChkCon"; ?></td>
</tr>
<tr>
  <td>Notes</td>
  <td ><?php echo "$Notes"; ?></td>
</tr>
<?php echo "Date Added:$today" ;?>
<?php echo "Advisor ID:" ." ". "$AdvisorID" ;?>
Name <?php echo "$Salutation" ." ". "$FirstName" ." ". "$LastName" ; ?>
Street Address <?php echo "$Address1"; ?>
Address 2 <?php echo "$Address2"; ?>
City, ST & Zip <?php echo "$City" .",". "$State" ." ". "$Zip" ; ?>
Company Name <?php echo "$Company"; ?>
Job Title <?php echo "$Title"; ?>

This is a question that is often asked. First, you can NOT put PHP into DIV’s.

PHP is server side and the results must be posted to a browser. Posted results from PHP can go into a new page.

But, there is a solution. You can use an iFrame instead of a DIV. You set up your button to call a Javascript function ( <submit blah blah blah ONCLICK=“GetPHPfile();”) . Then, set up a Javascript to change the source file of the iFrame. Once the button is clicked, it goes out and processes the PHP file that you name in the Javascipt and loads it into the iFrame. Here is some code…

Javascript:

<script language="JavaScript" type="text/javascript">
function buttonclicked(){
  document.getElementById('iFrame1').src = "NewPage.php?info="item3";
}
</script>

iFrame (I called it iFrame1 , no source needed yet…)

<iframe ID="iFrame1" src="" />

The button calls the Javascript when pressed. It calls your PHP code which is in a different file, I called this NewPage.php. In that code you do whatever you want in PHP. Also, note in the example, I added "?info=“item3” … This is a way to pass info to the PHP file so it can parse data and return whatever you want. It is not needed for most. Hope this helps, Good luck…

Sponsor our Newsletter | Privacy Policy | Terms of Service