Jump to content


php navigation + form actions?


8 replies to this topic

#1 Marxx

    Young Padawan

  • Members
  • Pip
  • 116 posts
  • Gender:Male
  • Location:Finland

Posted 08 January 2006 - 04:41 AM

Hi!

I just made my website to use php navigation system but one problem occured:

In index page i got this line in content area:

<?php
	  switch($_GET['id']) { default: include('main.php'); 
	  break; 
	  case 'submit': include('submit.php');   
	  break;
	  case "forum": include('index.php');   
	  break;
	  case "search": include('search.php');
	  break; 
?>

QUESTION: I got this one script which use this kind of action:
<form method=GET action="$PHP_SELF?subaction=search">

How can i make it work correct in this navigation system?


Thanks for all help!

#2 xwazawx

    Young Padawan

  • Members
  • Pip
  • 45 posts

Posted 08 January 2006 - 07:23 AM

Hey,
<form method=GET action="$PHP_SELF?subaction=search">
Is the form you posted, according to your PHP code the variable you want to send to the page is id, not subaction?

<form method=GET action="$PHP_SELF?id=search">
Should do it? I assume that the form tag is being printed with PHP..

I hope this comes as some help, otherwise I'll offer more help - but I'm not able to unless you're a bit more specific with coding and where everything is at :ph34r:

Edited by UnseenXS, 08 January 2006 - 07:24 AM.


#3 Av-

    I Feel Left Out

  • Members
  • PipPipPipPip
  • 1,971 posts
  • Gender:Male
  • Location:10 ft. below sea level

Posted 08 January 2006 - 07:43 AM

just do it like this
<form method=GET action="index.php?id=search">


#4 Marxx

    Young Padawan

  • Members
  • Pip
  • 116 posts
  • Gender:Male
  • Location:Finland

Posted 08 January 2006 - 08:09 AM

View PostUnseenXS, on Jan 8 2006, 12:23 PM, said:

Hey,
<form method=GET action="$PHP_SELF?subaction=search">
Is the form you posted, according to your PHP code the variable you want to send to the page is id, not subaction?

Form is in search.php where form is doing subaction


-> Index.php | Where user click hes way to search page
--> Search.php | Where user type hes searchwords
----> subaction=search | Where search script is doing searching and print results in another page..

I use one index page where php navigation includes another pages so can't just point form action to search.php because there is no layout what so ever. It has to point in index page whit include..

I've tried your succestions but it just directing me in index page!? :P

I hope this helps whit helping! :P

#5 Av-

    I Feel Left Out

  • Members
  • PipPipPipPip
  • 1,971 posts
  • Gender:Male
  • Location:10 ft. below sea level

Posted 08 January 2006 - 10:50 AM

<form method=GET action="index.php?id=search&subaction=search">


#6 Marxx

    Young Padawan

  • Members
  • Pip
  • 116 posts
  • Gender:Male
  • Location:Finland

Posted 08 January 2006 - 11:37 AM

nouh.. :P

It is not going to work! Damn.. Maybe i just should make hole search page fully own page and try to go that way for sollution.

#7 tiki

    Young Padawan

  • Members
  • Pip
  • 259 posts
  • Gender:Male
  • Location:California

Posted 08 January 2006 - 03:29 PM

Shouldt default be at the end of the cases? Im not sure but that happens to me.

#8 xwazawx

    Young Padawan

  • Members
  • Pip
  • 45 posts

Posted 08 January 2006 - 09:16 PM

I think I understand the problem..

$PHP_SELF does not include the get variables that are in the url. e.g. index.php?id=search will return index.php.

Actually, you're unable to set the action to to a page and set the get variables that way (which is perhaps why there's no luck?).

<form method=GET action="index.php">
<input type="hidden" name="id" value="search">
<input type="hidden" name="subaction" value="search">

That is the code avalanche posted except improved , that might achieve you what you're after? Otherwise try using the hidden input fields to define the variable and value as opposed to setting the action to the desired result B)

You should also view the source of the page constantly - from that you can generally get an idea as to wether the PHP is returning the right information. If it is not returning what you wanted then you can get some idea of where to look to fix :)

Hopefully this helps :o ?

#9 Marxx

    Young Padawan

  • Members
  • Pip
  • 116 posts
  • Gender:Male
  • Location:Finland

Posted 19 January 2006 - 04:44 PM

No, i tried all suggestions and many more but didn't work. So i and my case and forget php navigation! :(
Now i have simple php pages where i'm including header, left panel and footer.. Works and like it! :)

Thanks all helps tho... respect!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users