The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> multiple actions under a single form
shankar from vizag
post Nov 12 2014, 05:27 AM
Post #1


Advanced Member
****

Group: Members
Posts: 202
Joined: 18-June 13
Member No.: 19,316



Good afternoon

I kept two submit buttons under a html form. One button is for saving records to database and another one is to retrieve data into another page. Under form action I referred a .php file, in which I have given code for both saving and retrieving. I succeeded in saving whereas I am not able to succeed in retrieving the data from the database.

When the user press the second button namely show details it should redirect to another page and in that new page all the details should show.

Can it be possible to give two .php files under form action tag ?

Please assist in this regard.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Nov 12 2014, 06:43 AM
Post #2


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



No it is not possible to have more than one address (.php file, whatever) as the action of a form. Of course it is perfectly possible to have one script which decides what to do on the basis of which submit button was pressed. You find out which from the name and value arguments on the Submit button, which are only passed when that button is pressed.

CODE

<input type=submit name=act1 value="Do something">
<input type=submit name=act2 value="Do something else">

inside the script:

if($_GET['act1']) ... then do something
if($_GET['act2']) ... then do something else


Hope this helps. (You may need to check the details yourself.)
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Nov 12 2014, 12:49 PM
Post #3


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,734
Joined: 9-August 06
Member No.: 6



What happens instead when the second button is clicked?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Nov 12 2014, 01:26 PM
Post #4


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



QUOTE(pandy @ Nov 13 2014, 02:49 AM) *

What happens instead when the second button is clicked?


Sorry, don't understand the question. Instead of what? Or are you asking the OP for details of what the second thing was?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Nov 12 2014, 04:24 PM
Post #5


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,734
Joined: 9-August 06
Member No.: 6



Yes, I'm asking the OP. Instead of what should happen. We only know clicking the second button doesn't work as expected, but not how it fails.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Nov 12 2014, 05:22 PM
Post #6


.
********

Group: WDG Moderators
Posts: 9,666
Joined: 10-August 06
Member No.: 7



QUOTE(shankar from vizag @ Nov 12 2014, 11:27 AM) *

When the user press the second button namely show details it should redirect to another page and in that new page all the details should show.

In my understanding, there are three URLs involved: one each for the form, the PHP script and the details page. If you redirect from the PHP script to the details page you need a way to transfer the details to the latter (e.g. in the querystring, if that's appropriate).

Can you post the HTML of the form and its PHP script?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
shankar from vizag
post Nov 13 2014, 04:52 AM
Post #7


Advanced Member
****

Group: Members
Posts: 202
Joined: 18-June 13
Member No.: 19,316



Thank you Brian for your reply

May I have any example of such kind for my better understand.

shankar sb


QUOTE(Brian Chandler @ Nov 12 2014, 05:13 PM) *

No it is not possible to have more than one address (.php file, whatever) as the action of a form. Of course it is perfectly possible to have one script which decides what to do on the basis of which submit button was pressed. You find out which from the name and value arguments on the Submit button, which are only passed when that button is pressed.

CODE

<input type=submit name=act1 value="Do something">
<input type=submit name=act2 value="Do something else">

inside the script:

if($_GET['act1']) ... then do something
if($_GET['act2']) ... then do something else


Hope this helps. (You may need to check the details yourself.)

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
shankar from vizag
post Nov 13 2014, 04:58 AM
Post #8


Advanced Member
****

Group: Members
Posts: 202
Joined: 18-June 13
Member No.: 19,316



Sir

another doubt is, I placed a html textbox on a form, I need it to be display sys. date of the server automatically.

<html>
<head>
<script>

What is the script I have to give here to get the date as dd-mm-yyyy format


</script>
</head>

<body>
Date: <input type = "text" name="date" id="date"/>
</body>
</html>

waiting for your reply

shankar sb


QUOTE(Brian Chandler @ Nov 12 2014, 05:13 PM) *

No it is not possible to have more than one address (.php file, whatever) as the action of a form. Of course it is perfectly possible to have one script which decides what to do on the basis of which submit button was pressed. You find out which from the name and value arguments on the Submit button, which are only passed when that button is pressed.

CODE

<input type=submit name=act1 value="Do something">
<input type=submit name=act2 value="Do something else">

inside the script:

if($_GET['act1']) ... then do something
if($_GET['act2']) ... then do something else


Hope this helps. (You may need to check the details yourself.)

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Nov 13 2014, 07:57 AM
Post #9


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



QUOTE(shankar from vizag @ Nov 13 2014, 06:52 PM) *

Thank you Brian for your reply

May I have any example of such kind for my better understand.


Well, what I wrote was meant to be an example. I'm happy to try to help, but not to do the job for you.

But if you have two php files (one.php and two.php) and you want to run just one of them, the easy way is something like:

CODE

(File which.php)

if($_GET['act1']) include("one.php");
if($_GET['act2']) include("two.php");


This should be all you need. This way all the $_GET values passed from the form are automatically there when either of the scripts runs.

Incidentally, if you want the server time info, you need to write it in the page on the server, presumably using PHP.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 20th May 2024 - 02:35 PM