Jump to content

Two actions, Two buttons on One form?


bolty2uk

Recommended Posts

Sorry if this has been touched on before but i am having problems finding a definite solution.

 

Also this may be more of a javascript issue so i do apologise if i have chosen the wrong forum to start.

 

Ok. I have a simple form where a user can enter details. What i need from this form is two seperate buttons with different actions.

 

Basically they click 'Button One' then they go with all form info to one page.

And if they click 'Button Two' then they go with all info to another page.

 

I have seen possible solutions with javascript but this will require the user to have javascript enabled.

 

So im just after advice on the best solution to this.

 

thanks for any responce this may generate.

 

Bolty2uk

Link to comment
https://forums.phpfreaks.com/topic/56217-two-actions-two-buttons-on-one-form/
Share on other sites

Case Switch is a good option, I use it with a refresh option on this page.

<?
echo "<head>";
echo "<title>Software Design</title>";
echo "</head>";
echo "<body>";
echo "<center>";
echo "<form method=GET name=form1 action='$PHP_SELF'>"; 
echo  "<input type=submit name=cmd value='Yes'>";
echo "<input type=submit name=cmd value='Now'>";
echo "</form>";
echo "</center>";
echo "</body>";
echo "</html>";

Function RedirectPage($page) {
echo "<META HTTP-EQUIV='REFRESH' CONTENT='0; url=".$page."'>";
}

switch($_REQUEST['cmd']){
case "Yes";
RedirectPage('yes.php');
break;
case "No";
RedirectPage('no.php');
break;
  }
?>

Archived

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

×
×
  • Create New...

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.