Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple submit buttons not working
    primarykey
    data
    text
    <p>I am looking for a solution to multiple submit buttons using simple php.</p> <p>Here is my form code </p> <pre><code> &lt;!-- Widget Starts --&gt; &lt;div class="widget"&gt; &lt;div class="title js_opened"&gt; &lt;div class="icon"&gt;&lt;img src="themes/&lt;?php echo WEBSITE_ADMIN_PANEL_THEME; ?&gt;/images/icons/navigation/pages&lt;?php echo $retina_suffix; ?&gt;.png" width="24" height="24" alt="" /&gt;&lt;/div&gt; &lt;span&gt;Fill The Fields Marked With *&lt;/span&gt; &lt;/div&gt; &lt;div class="content"&gt; &lt;div class="form_row first"&gt; &lt;label&gt;Title&lt;span class="star"&gt;&amp;nbsp;*&lt;/span&gt;&lt;/label&gt; &lt;div class="form_right"&gt;&lt;input type="text" name="title" maxlength="100" value="&lt;?php echo $session-&gt;getSession("pages_title") ;?&gt;" /&gt;&lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="form_row last"&gt; &lt;label&gt;Description&lt;span class="star"&gt;&amp;nbsp;*&lt;/span&gt;&lt;/label&gt; &lt;div class="form_right"&gt;&lt;textarea name="description" class="Editor"&gt;&lt;?php echo $session-&gt;getSession("pages_description") ;?&gt;&lt;/textarea&gt;&lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- Widget Ends --&gt; &lt;!-- Widget Starts --&gt; &lt;div class="widget"&gt; &lt;div class="title js_opened"&gt; &lt;div class="icon"&gt;&lt;img src="themes/&lt;?php echo WEBSITE_ADMIN_PANEL_THEME; ?&gt;/images/icons/navigation/meta&lt;?php echo $retina_suffix; ?&gt;.png" width="24" height="24" alt="" /&gt;&lt;/div&gt; &lt;span&gt;Metadata Information&lt;/span&gt; &lt;/div&gt; &lt;div class="content"&gt; &lt;div class="form_row first"&gt; &lt;label&gt;Title&lt;/label&gt; &lt;div class="form_right"&gt;&lt;input type="text" name="meta_title" maxlength="250" value="&lt;?php echo $session-&gt;getSession("pages_meta_title") ;?&gt;" /&gt;&lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="form_row"&gt; &lt;label&gt;Keywords&lt;/label&gt; &lt;div class="form_right"&gt;&lt;textarea id="meta_keywords" name="meta_keywords"&gt;&lt;?php echo $session-&gt;getSession("pages_meta_keywords") ;?&gt;&lt;/textarea&gt;&lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="form_row"&gt; &lt;label&gt;Description&lt;/label&gt; &lt;div class="form_right"&gt;&lt;textarea id="meta_description" name="meta_description"&gt;&lt;?php echo $session-&gt;getSession("pages_meta_description") ;?&gt;&lt;/textarea&gt;&lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="form_row"&gt; &lt;label&gt;Robot&lt;/label&gt; &lt;div class="form_right"&gt; &lt;select name="meta_robot"&gt; &lt;option value=""&gt;Please Choose An Option&lt;/option&gt; &lt;option value="index, follow" &lt;?php if ($session-&gt;getSession("pages_meta_robot")=="index, follow") echo "selected=\"selected\""; ?&gt; &gt;index, follow&lt;/option&gt; &lt;option value="noindex, follow" &lt;?php if ($session-&gt;getSession("pages_meta_robot")=="noindex, follow") echo "selected=\"selected\""; ?&gt; &gt;noindex, follow&lt;/option&gt; &lt;option value="index, nofollow" &lt;?php if ($session-&gt;getSession("pages_meta_robot")=="index, nofollow") echo "selected=\"selected\""; ?&gt; &gt;index, nofollow&lt;/option&gt; &lt;option value="noindex, nofollow" &lt;?php if ($session-&gt;getSession("pages_meta_robot")=="noindex, nofollow") echo "selected=\"selected\""; ?&gt; &gt;noindex, nofollow&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="form_row last"&gt; &lt;label&gt;Author&lt;/label&gt; &lt;div class="form_right"&gt;&lt;input type="text" name="meta_author" maxlength="50" value="&lt;?php echo $session-&gt;getSession("pages_meta_author") ;?&gt;" /&gt;&lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- Widget Ends --&gt; &lt;div class="form_buttons"&gt; &lt;input type="submit" name="add" value="Save" /&gt;&amp;nbsp;&lt;span class="no_mobile"&gt;&amp;nbsp;&lt;/span&gt; &lt;input type="submit" name="add" value="Save &amp;amp; New" /&gt;&amp;nbsp;&lt;span class="no_mobile"&gt;&amp;nbsp;&lt;/span&gt; &lt;input type="reset" value="Clear" /&gt; &lt;/div&gt; &lt;/form&gt; &lt;!-- Form Ends --&gt; </code></pre> <p>and here is my php processing page code (I have omitted the part which saves the form results into the database.</p> <pre><code>&lt;?php $submit = $_POST["add"]; if ($submit == "Save") { header("location:pages_view.php?type=success&amp;msg=" .urlencode($msg)); exit(); } else { header("location:pages_add.php?type=success&amp;msg=" .urlencode($msg)); exit(); } ?&gt; </code></pre> <p>What I want to achieve is that if I press the 1st submit button in form i.e Save, then it should save the form and go to view page and if I press the 2nd submit button i.e Save &amp; New then it should save the form data and go back to the same page i.e add page.</p> <p>Please help me to find out the solution.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload