LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-12-2005, 07:44 AM   #1
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676
Blog Entries: 7

Rep: Reputation: 32
PHP: submitting a form to one of two pages


Hi guys Ive got a page that allows me to delete or modify users.....the page lists all the users with a radio button besides them and at the end of hte page the user can click either delete or modify ........if the user clicks delete I will delete the user and return the user to the same page again ( Ive already done that, the form action submits to itself)....if the users clicks modify I want to take the user to another page with the value of the radio button he chose






if (isset($_POST['delete'])){
//continue on this page done
}
if (isset($_POST['modify']){
//go to modify page and take radio button value there "????"
}
 
Old 11-12-2005, 08:59 AM   #2
pnellesen
Member
 
Registered: Oct 2004
Location: Missouri, USA
Distribution: Slackware 12.2, Xubuntu 9.10
Posts: 371

Rep: Reputation: 31
Something like this, maybe?


if (isset($_POST['delete'])){
//continue on this page done
}
if (isset($_POST['modify']){
//go to modify page and take radio button value there "????"
header('Location: modify.php?value=blah');
}
 
Old 11-12-2005, 09:02 AM   #3
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676

Original Poster
Blog Entries: 7

Rep: Reputation: 32
but if I use that method can I pass multiple values ?
 
Old 11-12-2005, 09:19 AM   #4
pnellesen
Member
 
Registered: Oct 2004
Location: Missouri, USA
Distribution: Slackware 12.2, Xubuntu 9.10
Posts: 371

Rep: Reputation: 31
Depends on how many you want to pass, how big they are. You could just string them together like:

header('Location: modify.php?value1=blah&value2=bleh&value3=blue');
 
Old 11-12-2005, 09:38 AM   #5
ronsha
Member
 
Registered: Oct 2005
Posts: 30

Rep: Reputation: 15
I would do it differently. I wouldn't send the 'delete' to the same page. I would have another radio button that specified 'delete' or 'modify' and submit the form to a new page where:

if (isset($_POST['modify']))
{

//modify
}

else
if (isset($_POST['delete']))
{

//delete
}
 
Old 11-12-2005, 11:17 AM   #6
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676

Original Poster
Blog Entries: 7

Rep: Reputation: 32
Iam really new to PHP... Iam a Java programmer and the idea in java is to spare code whenever you can and reuse it.....if I would send the delete to another page I would have to represent the same code of the first page on that page since the user might want to delete another user...
Is it normal in PHP to represent the same code in diff page although there is no real need for it ?
 
Old 11-12-2005, 04:53 PM   #7
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 51
I think you can include other PHP files with the require() function or something. That way, you can use code from many files from one file.
 
Old 11-12-2005, 05:40 PM   #8
pnellesen
Member
 
Registered: Oct 2004
Location: Missouri, USA
Distribution: Slackware 12.2, Xubuntu 9.10
Posts: 371

Rep: Reputation: 31
You may want to go to the official PHP manual if you haven't already - http://www.php.net/manual/en/

It's really thorough, and it should answer any particular syntax/usage questions you might have. Like any other language, your code reuse really depends on you - usually, when I'm doing forms like the one you're doing, I just have different functions in the same template (sometimes via "include()" as the previous poster suggested), and keep resubmitting the form to the same page, varying the value of a hidden form variable depending upon which part of the template I want processed.
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
No form output in PHP jabfinger Programming 2 07-15-2005 06:48 PM
PHP form help Zeppelin_Fan Programming 5 03-24-2005 04:47 PM
Submitting a POST Form with Links HappyDude Programming 0 10-24-2004 02:07 AM
HTML, PHP, forms, submitting data Problem Silent1 Programming 3 08-31-2004 03:03 PM
php/form kev82 Programming 0 02-25-2004 06:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration