Pinder Posted November 18, 2009 Share Posted November 18, 2009 Hello Everyone, I'm new. I've got a question regarding a return button on my form. What is suppose to happen is a user can enter information about a lesson plan, then you can submit the lesson plan by email or display it in a preview format for printing. The problem I'm having is in my preview section of code the return button returns me to the orginal form, but I require the variables to be displayed that were previously entered and currently the variables are not returning. If anyone can help thanks. This is my code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Lesson Plan</title> <LINK REL=StyleSheet HREF="../style.css" TYPE="text/css" MEDIA=screen> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <fieldset> <legend>Lesson Plan</legend> <form method="GET" name="LessonPlanForm" action="/TrainingDatabase/LessonPlan/index.php"> <?PHP $emailTo = 'alex.pinder@address.com'; $session = $_GET['session']; $module = $_GET['module']; $subject = $_GET['subject']; $jobTask = $_GET['jobTask']; $trainingObjective = $_GET['trainingObjective']; $subobjective1 = $_GET['subobjective1']; $subobjective2 = $_GET['subobjective2']; $subobjective3 = $_GET['subobjective3']; $subobjective4 = $_GET['subobjective4']; $subobjective5 = $_GET['subobjective5']; $instructionalTechniques = $_GET['instructionaltechniques']; $trainingAids = $_GET['trainingaids']; $trainingTime = $_GET['trainingtime']; $references = $_GET['references']; if ($session == 'S1A'){$select01 = 'selected';} elseif($session == 'S1B'){$select02 = 'selected';} elseif($session == 'S2A'){$select03 = 'selected';} elseif($session == 'S2B'){$select04 = 'selected';} elseif($session == 'S3A'){$select05 = 'selected';} elseif($session == 'S3B'){$select06 = 'selected';} elseif($session == 'S4A'){$select07 = 'selected';} elseif($session == 'S4B'){$select08 = 'selected';} elseif($session == 'FSA'){$select09 = 'selected';} elseif($session == 'FSB'){$select10 = 'selected';} elseif($session == 'FSC'){$select11 = 'selected';} if (!isset($_REQUEST['Submit']) && !isset($_REQUEST['Reset']) && !isset($_REQUEST['Preview']) && !isset($_REQUEST['Return'])|| (!isset($_REQUEST['Submit']) && !isset($_REQUEST['Reset']) && !isset($_REQUEST['Preview']) && isset($_REQUEST['Return']))){ ?> Session:<br/> <select name="session"> <option value="S1A" <?PHP echo $select01;?>>Sector 1 Session A</option> <option value="S1B" <?PHP echo $select02;?>>Sector 1 Session B</option> <option value="S2A" <?PHP echo $select03;?>>Sector 2 Session A</option> <option value="S2B" <?PHP echo $select04;?>>Sector 2 Session B</option> <option value="S3A" <?PHP echo $select05;?>>Sector 3 Session A</option> <option value="S3B" <?PHP echo $select06;?>>Sector 3 Session B</option> <option value="S4A" <?PHP echo $select07;?>>Sector 4 Session A</option> <option value="S4B" <?PHP echo $select08;?>>Sector 4 Session B</option> <option value="FSA" <?PHP echo $select09;?>>Fundamental Skills Session A</option> <option value="FSB" <?PHP echo $select10;?>>Fundamental Skills Session B</option> <option value="FSC" <?PHP echo $select11;?>> Fundamental Skills Session C</option> </select><br/> Module:<br/> <textarea name="module" rows="2" cols="60"><?php echo "$module";?></textarea><br/> Subject:<br/> <textarea name="subject" rows="1" cols="90"><?php echo "$subject";?></textarea><br/> Job Task:<br/> <textarea name="jobTask" rows="1" cols="90"><?php echo "$jobTask";?></textarea><br/> Training Objective:<br/> <textarea name="trainingObjective" rows="3" cols="90"><?php echo "$trainingObjective";?></textarea><br/> Sub-Objectives or Steps:<br/> 1.<textarea name="subobjective1" rows="3" cols="50" value=<?php echo $subobjective;?>></textarea><br/> 2.<textarea name="subobjective2" rows="3" cols="50"><?php echo $subobjective2;?></textarea><br/> 3.<textarea name="subobjective3" rows="3" cols="50"><?php echo $subobjective3;?></textarea><br/> 4.<textarea name="subobjective4" rows="3" cols="50"><?php echo $subobjective4;?></textarea><br/> 5.<textarea name="subobjective5" rows="3" cols="50"><?php echo $subobjective5;?></textarea><br/> Instructional Techniques:<br/> <textarea name="instructionaltechniques" rows="5" cols="90"><?php echo "$instructionalTechniques";?></textarea><br/> Training Aids Required:<br/> <textarea name="trainingaids" rows="3" cols="90"><?php echo "$trainingAids";?></textarea><br/> Training Time Required:<br/> <select name="trainingtime" value=<?php echo "$trainingTime"; ?>> <option value="30 Mintues">30 Minutes</option> <option value="1 Hour">1 Hour</option> <option value="1.5 Hours">1.5 Hours</option> <option value="2 Hours">2 Hours</option> <option value="2.5 Hours">2.5 Hours</option> <option value="3 Hours">3 Hours</option> <option value="3.5 Hours">3.5 Hours</option> <option value="4 Hours">4 Hours</option> <option value="4.5 Hours">4.5 Hours</option> <option value="5 Hours">5 Hours</option> <option value="5.5 Hours">5.5 Hour</option> <option value="6 Hours">6 Hours</option> <option value="6.5 Hours">6.5 Hours</option> <option value="7 Hours">7 Hours</option> <option value="7.5 Hours">7.5 Hours</option> <option value="8 Hours">8 Hours</option> </select></br> References:<br/> <textarea name="references" rows="4" cols="90"><?PHP echo "$references";?></textarea><br/> <input name="Submit" type="submit" value="Submit"/> <input name="Reset" type="reset" value="Clear"/> <input name="Preview" type="submit" value="Preview"/> <?PHP } if (isset($_REQUEST['Reset'])){ unset($session); unset($module); unset($subject); unset($jobTask); unset($trainingObjective); unset($subobjective1); unset($subobjective2); unset($subobjective3); unset($subobjective4); unset($subobjective5); unset($instructionalTechniques); unset($trainingAids); unset($trainingTime); unset($references); } if (!isset($_REQUEST['Submit']) && !isset($_REQUEST['Reset']) && isset($_REQUEST['Preview']) && !isset($_REQUEST['Return'])){ ?> <Session:<br/><?PHP echo $session;?></br/> Module:<br/><?PHP echo $module;?><br/> Subject:<br/><?PHP echo $subject;?><br/> Job Task:<br/><?PHP echo $jobTask;?><br/> Training Objective:<br/><?PHP echo $trainingObjective;?><br/> Sub-Objective 1:<br/><?PHP echo $subobjective1;?><br/> Sub-Objective 2:<br/><?PHP echo $subobjective2;?><br/> Sub-Objective 3:<br/><?PHP echo $subobjective3;?><br/> Sub-Objective 4:<br/><?PHP echo $subobjective4;?><br/> Sub-Objective 5:<br/><?PHP echo $subobjective5;?><br/> Instructional Techniques:<br/><?PHP echo $instructionalTechniques;?><br/> Training Aids:<br/><?PHP echo $trainingAids;?><br/> Training Time:<br/><?PHP echo $trainingTime;?><br/> References:<br/><?PHP echo $references;?><br/> <input type='submit' value='Submit' name='Submit'/> <input type='submit' value='Return' name='Return'/> </form></fieldset> <?PHP } if(isset($_REQUEST['Submit']) && !isset($_REQUEST['Reset']) && !isset($_REQUEST['Preview']) && !isset($_REQUEST['Return'])){ $message = "<fieldset><form><legend>Lesson Plan</legend>Session:<br/>$session</br/> Module:<br/>$module<br/> Subject:<br/> $subject<br/> Job Task:<br/> $jobTask<br/> Training Objective:<br/> $trainingObjective<br/> Sub-Objective 1:<br/> $subobjective1<br/> Sub-Objective 2:<br/> $subobjective2<br/> Sub-Objective 3:<br/> $subobjective3<br/> Sub-Objective 4:<br/> $subobjective4<br/> Sub-Objective 5:<br/> $subobjective5<br/> Instructional Techniques:<br/> $instructionalTechniques<br/> Training Aids:<br/> $trainingAids<br/> Training Time:<br/> $trainingTime<br/> References:<br/> $references<br/> </form></fieldset>"; mail($emailTo,$subject,$message); echo "Form submit complete<br/>"; echo "<input type='submit' value='Return' name='Return'/><br/>"; ?> </body> </form> </fieldset> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/182034-return-button-function/ Share on other sites More sharing options...
premiso Posted November 18, 2009 Share Posted November 18, 2009 Before your next post, please take the time to read the red writing right above the post button, names the Rules. All your code should be posted within the code tags. Aside from you not reading the rules before posting here is an example of how to accomplish what you want: <?php if (isset($_POST['Return'])) { if (empty($_POST['test']) || $_POST['test'] != 'test') { $error = 1; } if ($error != 1) { echo "Thank you for submitting your information"; exit; } } ?> <form name="testform" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <input type="text" name="test" value="<?php echo $_POST['test']; ?>" /><br /> <input type="submit" value="Return" name="Return" /> </form> I believe that is what you were looking for, if "test" was not entered into that text box it errors and puts what was previously written back in after the submit buttons was pushed... Quote Link to comment https://forums.phpfreaks.com/topic/182034-return-button-function/#findComment-960163 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.