Jump to content


This topic is now archived and is closed to further replies.


Multiple submit buttons

Recommended Posts


I have a form for DJ's to enter the details of the clubs they DJ at, on completing the form i want to offer the user 2 options


option one - to submit the data and continue to the next step of the form


option two - to submit the data and reset the existing form to enable them to submit details of further clubs.


Is it possible to do this from multiple submit buttons on one page?


any help appreciated

Share this post

Link to post
Share on other sites

This is possible


Step 1 set up the form with the two buttons, giving them distinct names like

<form method=post action='page.php'>
// your form fields
<input type='submit' value='Displayname1', name='button'>
<input type='submit' value='Displayname2', name='button'>


Step 2 in the page which the form calls, 'page.php' in the example, create a branch for which button is pressed like


if ($button == "Displayname1"){// set of commands}

elseif ($button == "Displayname2"){// set of commands}


Hope that helps


EDIT: Oops the earlier code had an error in it now corrected

Share this post

Link to post
Share on other sites

Thanks for your help

i kind of understand the principle but the problem is dreamweaver is doing most of my coding. (i'm trying to break this habit) When i try and insert your suggestion, dreamweaver spews out errors. I'll post you the code with the hope you may be able to make some sense of it, apologies though, i know there's a lot of it.




session_start(); ?><?php require_once('Connections/mattyboy.php'); ?>


function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")


$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;


switch ($theType) {

case "text":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";


case "long":

case "int":

$theValue = ($theValue != "") ? intval($theValue) : "NULL";


case "double":

$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";


case "date":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";


case "defined":

$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;



return $theValue;



$editFormAction = $_SERVER['PHP_SELF'];

if (isset($_SERVER['QUERY_STRING'])) {

$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);



if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {

$insertSQL = sprintf("INSERT INTO upshotaltclubvenues (email, clubname, clubaddressline1, clubaddressline2, clubtown, nightofthewek, capacity, promoter, promotertelephonenumber, promoteremail, albumplayback, dvdscreens, liveacts, celebritydjs, productpromotion) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",

GetSQLValueString($_POST['email'], "text"),

GetSQLValueString($_POST['clubname'], "text"),

GetSQLValueString($_POST['clubaddressline1'], "text"),

GetSQLValueString($_POST['clubaddressline2'], "text"),

GetSQLValueString($_POST['clubtown'], "text"),

GetSQLValueString($_POST['nightoftheweek'], "text"),

GetSQLValueString($_POST['capacity'], "text"),

GetSQLValueString($_POST['promoter'], "text"),

GetSQLValueString($_POST['promotertelephonenumber'], "text"),

GetSQLValueString($_POST['promoteremail'], "text"),

GetSQLValueString(isset($_POST['albumplayback']) ? "true" : "", "defined","'Y'","'N'"),

GetSQLValueString(isset($_POST['dvdscreens']) ? "true" : "", "defined","'Y'","'N'"),

GetSQLValueString(isset($_POST['liveacts']) ? "true" : "", "defined","'Y'","'N'"),

GetSQLValueString(isset($_POST['celebritydjs']) ? "true" : "", "defined","'Y'","'N'"),

GetSQLValueString(isset($_POST['productpromotion']) ? "true" : "", "defined","'Y'","'N'"));


mysql_select_db($database_mattyboy, $mattyboy);

$Result1 = mysql_query($insertSQL, $mattyboy) or die(mysql_error());


$insertGoTo = "reg2_1.php";

if (isset($_SERVER['QUERY_STRING'])) {

$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";

$insertGoTo .= $_SERVER['QUERY_STRING'];


header(sprintf("Location: %s", $insertGoTo));



mysql_select_db($database_mattyboy, $mattyboy);

$query_venues = "SELECT * FROM upshotaltclubvenues";

$venues = mysql_query($query_venues, $mattyboy) or die(mysql_error());

$row_venues = mysql_fetch_assoc($venues);

$totalRows_venues = mysql_num_rows($venues);



<form action="<?php echo $editFormAction; ?>" method="POST" name="form1">

Share this post

Link to post
Share on other sites

I am not familiar with dreamweaver. I have abandoned these sort of apps because they load the pages and the web site with so much extraneous guff 'just in case' that it is hard to unravel, as you are finding. Trouble is: break one of dreamweaver's little quirks and the page falls over. At least that's what I found with frontpage before seeing the light.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.