home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 3508
Discussions: 188,361, Posts: 2,243,343, Members: 232,588
Old May 2nd, 2005, 01:49 AM   Digg it!   #1 (permalink)
Member
 
Join Date: Jan 2004
Posts: 242
php select form

Im trying to get a select form to pass some info to another page using php, but i can't seem to post the values correctly i guess. I have a regular submit form that is working well but this select one is confusing me a little.
Code:
$where=!isset($_POST['where_to_go'])? NULL: $_POST['where_to_go'];
<form action="redirect.php" method="post">
        <select name="where_to_go" size=4>
        <option value="search"  SELECTED        >Search</option>
        <option value="add"             >Add objects to database</option>
        <option value="delete"          >Remove objects from database</option>
        <option value="edit"            >Edit objects in database</option>
        </select>
        <input type="submit" value="Go">
</form>
I used $_POST for the text submit form. I dont really know where to go from here.

edit: forgot about redirect.php:
Code:
<?
        if($where=='search'){
                header("Location: search.php");
        }
        else if($where=='add'){
                header("Location: add.php");
        }
        else if($where=='delete'){
                header("Location: delete.php");
        }
        else if($where=='edit'){
                header("Location: edit.php");
        }
        else{
                header("Location: auth.php");
        }
?>


Last edited by engineuity : May 2nd, 2005 at 01:51 AM.
engineuity is offline   Reply With Quote
Old May 2nd, 2005, 02:09 AM     #2 (permalink)
Perfetc Member
 
VHockey86's Avatar
 
Join Date: Jan 2003
Location: Maryland Suburbia
Posts: 4,327
To access the variable
Code:
 $where = $HTTP_POST_VARS['where_to_go'];
Put that in your redirect.php file.

$_POST is another way to access variables, this does not "give" them to the other script in any way.

The form posts the variables for you when you have the form method "post"

Your first line doesnt really make any sense to me either....
Code:
$where=!isset($_POST['where_to_go'])? NULL: $_POST['where_to_go'];
If it is not set, you are setting the variable equal to null. Why are you doing that?
"$where" does not need come up at all except in your other script that is processing the form. Just remove that line...


Last edited by VHockey86 : May 2nd, 2005 at 02:12 AM.
VHockey86 is offline   Reply With Quote
Old May 2nd, 2005, 02:10 AM     #3 (permalink)
Supporting our military
 
Bill in SD, CA's Avatar
 
Join Date: Oct 2002
Location: Bottom left of U.S.
Posts: 9,194
Can't help you on it but HTML Forums has a section for php threads.


Bill
__________________
*****
It is easy to be conspicuously "compassionate" if others are being forced to pay the cost. – Murray N. Rothbard

Bill in SD, CA is offline   Reply With Quote
Old May 2nd, 2005, 03:03 PM     #4 (permalink)
Member
 
Join Date: Jan 2004
Posts: 242
for the $where=xxxx part, I was trying to follow a web example...didnt understand it either, but I figured i would need to $_POST to send to another page, thanks for clearing that up.

OK, most of it works now, except for when i use the search value. It refreshes the page, but removes my session. The other values like add, delete, they work fine and redirect to that page. I tried taking out the "SELECTED" part but that didnt change anything.
engineuity is offline   Reply With Quote
Old May 2nd, 2005, 03:21 PM     #5 (permalink)
Member
 
Join Date: Jan 2004
Posts: 242
nm...figured it out. I guess "search" is a reserved value, like submit. I changed value="search" to value="search_p" and now everything is fine.
engineuity is offline   Reply With Quote
Old May 2nd, 2005, 04:12 PM     #6 (permalink)
Ultimate Member
 
Join Date: Jan 2003
Location: MA / NH
Posts: 1,497
Send a message via AIM to Blazer06
Well, first off, you are redirecting them twice, which is pointless. One redirect is all right, though you would be better off loading all from the same page in this case, IMO.

Code:
<?
  //Retrieves which page they would like to view.
  $page = $_POST["page"];
  
  //If they did not select a page (I.E. initial visit to this page)
  //Displays to them a form where they can pick where to go.
  if($page == ""){
    echo("
      <form action='#' method='post'>
        <select name='page' size=4>
          <option selected value='1'>Search</option>
          <option value='2'>Add objects to the database</option>
          <option value='3'>Remove objects from database</option>
          <option value='4'>Edit objects in database</option>
        </select>
        <input type='submit' value='Go'>
      </form>
    ");
  }

  //If there is a page selected, then the proper page is loaded.
  else{
    switch ($page) {
      case "1":
        require ("search.php");
        break;
      case "2":
        require ("add.php");
        break;
      case "3":
        require ("delete.php");
        break;
      case "4":
        require ("edit.php");
        break;
      default:
        require ("auth.php");
    }
  }
?>

-Blaze
Blazer06 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may 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 Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Form Help Rand Dusing Webmastering and Programming 16 September 4th, 2004 03:59 PM
php mail form data switch Webmastering and Programming 2 July 6th, 2004 04:09 PM
PHP form help rh71 Webmastering and Programming 5 January 24th, 2004 11:25 PM
PHP Form embj Webmastering and Programming 15 February 19th, 2003 09:39 PM
which way is proper PHP form Chooco Webmastering and Programming 3 March 22nd, 2002 02:08 AM

Most Active Discussions
Is It Just Me? (2866)
Obama plans to CUT taxes (48)
I think I just killed my computer w.. (24)
Folderchat Weekday thread (432)
Antec 300 bulk purchase? (11)
Worth the upgrade?? (14)
Dual Modem Connection for Internet? (6)
Titan quest and Immortal Throne, an.. (17)
FolderChat: Weekend time again! (375)
Recent Discussions
VISTA (1)
fuji finepix (6)
dual monitor, and video? (21)
Upgrading RAM (3)
Dual booting problem (2)
CS/COND ZERO AGAIN (2)
Best Graphic card under 110£ (2)
Screensavers in Vista (6)
Artifact problem (2)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 02:42 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28