Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Application and Web Development > PHP
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 08-19-2005, 03:01 PM   #1 (permalink)
salmanjoo
Registered User
 
Join Date: Aug 2005
Posts: 18
salmanjoo is on a distinguished road
Question can we make single form multiple submit buttons

hi guys
i want to make a single form having multiple submit buttons and every button have its different destination
like

form name="form1" method="post" action="">
<input type="text" name="textfield">
<input name="edit" type="submit" id="edit" value="edit">
<input name="upload" type="submit" id="upload" value="upload">
</form>

i want do do that on

on submit the edit button the next page will edit.php
on submit the upload button the next page will upload.php

is this possible
reply me soon plzzzzzzzzzzz
__________________
salmanjoo is offline   Reply With Quote
Old 08-19-2005, 04:06 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
why not just check for the value of the button name instead?

PHP Code:
<?
if($_POST['edit']){
  
// then do some edit stuff
}

if(
$_POST['upload']){
  
// then do some upload stuff
}
?>
__________________
testing 1 2 3
sde is online now   Reply With Quote
Old 08-19-2005, 07:08 PM   #3 (permalink)
salmanjoo
Registered User
 
Join Date: Aug 2005
Posts: 18
salmanjoo is on a distinguished road
it's fine but i want to go after submit to act the action file how can i give more than one file name in action
__________________
salmanjoo is offline   Reply With Quote
Old 08-19-2005, 07:30 PM   #4 (permalink)
salmanjoo
Registered User
 
Join Date: Aug 2005
Posts: 18
salmanjoo is on a distinguished road
<?php
if($_POST ['edit'])
{
?>
<form name="form1" method="post" action="editfile.php">
<?
}
if($_POST['upload'])
{
?>
<form name="form1" method="post" action="upload.php">
<?php
}
?>
<input type="text" name="textfield">
<input name="edit" type="submit" id="edit" value="EDIT">
<input name="upload" type="submit" id="upload" value="UPLOAD FILES">
</form>
__________________
salmanjoo is offline   Reply With Quote
Old 08-19-2005, 07:31 PM   #5 (permalink)
salmanjoo
Registered User
 
Join Date: Aug 2005
Posts: 18
salmanjoo is on a distinguished road
its not working about u r saying i did like this but its not working
is this rite way how should i do
<?php
if($_POST ['edit'])
{
?>
<form name="form1" method="post" action="editfile.php">
<?
}
if($_POST['upload'])
{
?>
<form name="form1" method="post" action="upload.php">
<?php
}
?>
<input type="text" name="textfield">
<input name="edit" type="submit" id="edit" value="EDIT">
<input name="upload" type="submit" id="upload" value="UPLOAD FILES">
</form>
__________________
salmanjoo is offline   Reply With Quote
Old 08-19-2005, 09:11 PM   #6 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 595
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
Instead of sending it to two different files, send the response to one file. That file will check the value of the form and take appropriate action.
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 08-20-2005, 04:31 AM   #7 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 635
DJMaze is on a distinguished road
HTML Code:
<form name="form1" method="post" action="file.php"> <input type="text" name="textfield"> <input type="submit" name="edit" id="edit" value="edit"> <input type="submit" name="upload" id="upload" value="upload"> </form>
file.php
PHP Code:
<?php
if ($_POST['edit']){
  include(
'edit.php');
} elseif (
$_POST['upload']){
  include(
'upload.php');
}
__________________
DJMaze is offline   Reply With Quote
Old 08-20-2005, 07:44 AM   #8 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
yeah, what they said
__________________
testing 1 2 3
sde is online now   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript form submit on SP2 cocoy HTML, XML, Javascript, AJAX 0 08-15-2005 07:18 PM
Can cascading text be converted to single line form? morpheuz PHP 7 06-08-2005 01:31 PM
javascript riddle: why won't my form submit from this text link? sde HTML, XML, Javascript, AJAX 6 09-29-2004 05:56 AM
Using javascript to submit a form sammy HTML, XML, Javascript, AJAX 2 07-15-2004 01:31 PM
HTML form preview then INSERT using PHP & MySQL SteveSoler PHP 5 07-07-2002 09:54 AM


All times are GMT -8. The time now is 11:52 PM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle