PHP Web Host - Quality Web Hosting For All PHP Applications Free RavenNuke(tm) Add Ons
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
Darrell3831
Worker
Worker


Joined: Feb 18, 2004
Posts: 244

PostPosted: Sun Mar 21, 2004 5:46 pm Reply with quote Back to top

How do you set up a form so that it can have two different submissions buttons?

I want to have a submit and a preview button.

This isent right:

Code:
echo "<form method=\"post\" action=\"admin.php\"><input type=\"hidden\" name=\"op\" value=\"insertCourse\"><input type=\"hidden\" name=\"cid\" value=\"$cid\">"
.
.
.
echo "<br><br>"
 ."<input type=\"submit\" name=\"op\" value=\""._PREVIEW."\">&nbsp;&nbsp;"
 ."<input type=\"submit\" name=\"op\" value=\""._COURSE_ADD."\">&nbsp;&nbsp;";


I have never seen the syntax for two submit buttons.

Thanks,
Darrell
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Sun Mar 21, 2004 6:24 pm Reply with quote Back to top

This, of course, is as much an HTML issue as a PHP issue Smile Actually, your syntax is correct. Your php program will have to test for the value of $op and then respond accordingly. Does that make sense? Here's a quick snippet to demonstrate
Code:
<form method="post">
<input type="submit" name="op" value="Preview">&nbsp;&nbsp;
<input type="submit" name="op" value="Submit">&nbsp;&nbsp;
</form>
<?
if (isset($_POST['op'])) {
   if ($_POST['op']=='Preview') {
      echo 'Do Preview Stuff Here';
   }
   else if ($_POST['op']=='Submit') {
      echo 'Do Submit Stuff Here';
   }
}
?>
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Darrell3831
Worker
Worker


Joined: Feb 18, 2004
Posts: 244

PostPosted: Sun Mar 21, 2004 7:16 pm Reply with quote Back to top

Thanks for taking the time to respond. I'm not sure I understand where the isset test goes.

My function was working before I decided I wanted to add the ability to preview the submission.

Here's what I have now.

Code:
/* Add Course */
function addCourse() {
   
   if (is_super()) {
      include("header.php");
      universityMenu();
      OpenTable();
       echo "<center><font class=\"title\"><b>"._COURSE_ADD."</b></font><br><br>"
         ."<font class=\"content\"><i>"._COURSE_ADVICE."</i></font></center><br>";
       CloseTable();
       echo "<BR>";
      OpenTable();
//       echo "<form method=\"post\" action=\"admin.php\"><input type=\"hidden\" name=\"op\" value=\"insertCourse\"><input type=\"hidden\" name=\"cid\" value=\"$cid\">" // original
       echo "<form method=\"post\" action=\"admin.php\"><input type=\"hidden\" name=\"cid\" value=\"$cid\">"  // testing
         ."<font class=\"option\"><b>"._COURSE_ADD."</b></font><br><br>"
         .""._UNIVERSITY_TITLE.": <input type=\"text\" name=\"title\" size=\"50\" value=\"$title\"><br><br>"
         .""._UNIVERSITY_DESCRIPTION.":<br><textarea name=\"description\" cols=\"90\" rows=\"15\">$description</textarea><br>"
          ."<font class=\"content\">"._HTMLALLOWED."<br>";
      displayAllowedHTML();
      echo "<br><br>"
         .""._COURSE_PRICE.": $<input type=\"text\" name=\"price\" size=\"6\" maxsize=\"6\" value=\"$price\"><br><br>"
         .""._UNIVERSITY_STATUS.": <select name=\"status\">";
         if ($status==0) {
            echo "<option value=\"0\"selected>inactive</option>"
            ."<option value=\"1\">active</option>";
         } else {
            echo "<option value=\"0\">inactive</option>"
            ."<option value=\"1\"selected>active</option>";
         }   
      echo "</select><br><br>"
      ."<input type=\"submit\" name=\"op\" value=\""._PREVIEW."\">&nbsp;&nbsp;" // testing
      ."<input type=\"submit\" name=\"op\" value=\""._COURSE_ADD."\">&nbsp;&nbsp;" // testing
//      ."<input type=\"submit\" value=\""._COURSE_ADD."\">" // original
      ."</form>";
       CloseTable();
      displayCopyright();
      include("footer.php");
   } else {
      accessDenied(2);
   }
}


If I take the hidden op value out at the top of the form and then add two new op values at the bottom of the form, where would I put the isset test?

Originally I was branching off the switch statement at the bottom of the course functions.

Code:
//   case "insertCourse":
   case ""._COURSE_ADD."":
   courseInsert($title, $description, $price, $status);
   break;


I don't understand how the program is supposed to flow after the submit buttons.

Sorry,
Darrell
View user's profile Send private message Visit poster's website
Darrell3831
Worker
Worker


Joined: Feb 18, 2004
Posts: 244

PostPosted: Mon Mar 22, 2004 2:21 pm Reply with quote Back to top

Nevermind,

I got it a little bit closer to working. I needed to include the language file in the the case file.

I'll letcha' know if I can't get it...

Thanks,
Darrell
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum