Go Back   Novahq.net Forum > Computers > Web design and Programming
FAQ Calendar Today's Posts Search

Web design and Programming Discuss website creation and other programming topics.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-21-2005, 08:44 PM
atholon is offline atholon
"ath-hole"

Join Date: Jan 2003
Location: Failville.
Posts: 11,357

Help Me Please!

Anyone know wtf is wrong with this? I have no errors but it is not working when I type in the filename and ?view=search nothing happens!! See anything wrong?

PHP Code:
<?php
if ($view "main") {
echo (
"<form action=\"http://www.nerdhq.net/forum/index.php?act=Search&amp;CODE=01\" method=\"post\" name=\"sForm\">");
echo (
"");
echo (
"        <table cellpadding=\"2\" cellspacing=\"0\" border=\"1\" width=\"520\" align=\"center\" style=\"border-collapse: collapse\" bordercolor=\"#C0C0C0\">");
echo (
"        <tr>");
echo (
"         <td bgcolor=\"#FAFAFA\" align=\"center\"><font color=\"#0046D5\" face=\"arial\"><b>Search by Keywords:</td>");
echo (
"         <td bgcolor=\"#FAFAFA\" align=\"center\"><font color=\"#0046D5\" face=\"arial\"><b>Filter by Member Name (optional):</td></tr>");
echo (
"         <tr> ");
echo (
"         <td width=\"50%\" align=\"center\">");
echo (
"             <input type=\"text\" maxlength=\"100\" size=\"35\" name=\"keywords\" id=\"keywords\" class=\"forminput\">");
echo (
"            </td>");
echo (
"         <td width=\"50%\" align=\"center\">");
echo (
"             <input type=\"text\" maxlength=\"100\" size=\"35\" name=\"namesearch\" class=\"forminput\" >");
echo (
"         </td>  ");
echo (
"        </tr>");
echo (
"        </table>");
echo (
"<br>");
echo (
"<table cellpadding=\"4\" cellspacing=\"0\" border=\"0\" width=\"100%\">         ");
echo (
"<tr>");
echo (
" <td class=\"pformstrip\" width=\"60%\" valign=\"middle\" align=\"center\"><font color=\"#0046D5\" face=\"arial\"><b>Search Where</b> <br>");
echo (
"    <input type=\"checkbox\" name=\"searchsubs\" value=\"1\" id=\"searchforum\" checked=\"checked\">&nbsp;<label for=\"searchsubs\">Search in forums?</label><br>");
echo (
"   <select name=\"forums[]\" class=\"forminput\" size=\"4\" multiple=\"multiple\" width=\"300\">");
echo (
"<option value=\"all\" selected=\"selected\">&raquo; All Forums</option>");
echo (
"<option value=\"c_4\" class=\"cat\">Tutorials</option>");
echo (
"<option value=\"12\">&middot;&middot;&nbsp;Hardware Tutorials &amp; FAQ's</option>");
echo (
"<option value=\"11\" class=\"sub\">&middot;&middot;&nbsp;Software Tutorials &amp; FAQ's</option>");
echo (
"</select>");
echo (
"   <br>");
echo (
"    <input type=\"checkbox\" name=\"searchsubs\" value=\"1\" id=\"searchsubs\" checked=\"checked\">&nbsp;<label for=\"searchsubs\">Search in child forums if sub category is chosen?</label><br>");
echo (
"");
echo (
"             <input type=\"hidden\" name=\"prune\" value=\"0\">");
echo (
"             <input type=\"hidden\" name=\"prune_type\" value=\"newer\">");
echo (
"             <input type=\"hidden\" name=\"sort_key\" value=\"forum_id\">");
echo (
"             <input type=\"hidden\" name=\"sort_order\" value=\"desc\">");
echo (
"                <input type=\"hidden\" name=\"search_in\" value=\"posts\">");
echo (
"             <input type=\"hidden\" name=\"result_type\" value=\"result_topics\">");
echo (
"");
echo (
"  </td>");
echo (
"</tr>");
echo (
"<tr>");
echo (
"    <td class=\"pformstrip\" colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Perform the search\" class=\"forminput\"></td>");
echo (
"</tr>");
echo (
"</table>");
echo (
"</form>");
echo (
"</b>");
}
if (
$view "search") {
echo (
"");
}
else {
echo (
"");
}
?>
__________________
Reply With Quote
  #2  
Old 05-21-2005, 09:13 PM
IcIshoot is offline IcIshoot

Join Date: Mar 2004
Location: Farmington Hills, MI
Posts: 1,473

to access the submitted variable you use

PHP Code:
$_GET['variablename'
So, in your case you could do

PHP Code:
$view $_GET['view'

Or, put this line at the begining of your script (I got it from the babstats code, and I use it a lot)

PHP Code:
if($HTTP_GET_VARS)    foreach($HTTP_GET_VARS    as $Key=>$Value) $$Key $Value
That line will turn each variable passed by the url into a usable variable in your script.

So using "script.php/?view=test" in your script you can use the variable "$view" and it will contain the value "test".

Same thing applies to post variables, just substitute $HTTP_GET_VARS with $HTTP_POST_VARS, or if you use my first example $_POST['variable name'].

Hope this helps,

IcI
Reply With Quote
  #3  
Old 05-21-2005, 09:17 PM
atholon is offline atholon
"ath-hole"

Join Date: Jan 2003
Location: Failville.
Posts: 11,357

OK. Thanks for input.

I think my problem is that it is it is executing the if statements even if it is not falling under the if conditions.

I'll mess around with your technique, is anything in my code bad that would cause if to execute everytime?

Yah so if I put $view="search"; right into the code it will execute the first IF anyway.
__________________
Reply With Quote
  #4  
Old 05-21-2005, 09:23 PM
IcIshoot is offline IcIshoot

Join Date: Mar 2004
Location: Farmington Hills, MI
Posts: 1,473

hmm... it is displaying every thing, even when I try using view=search..
Reply With Quote
  #5  
Old 05-21-2005, 09:25 PM
atholon is offline atholon
"ath-hole"

Join Date: Jan 2003
Location: Failville.
Posts: 11,357

Yeah, so it is screwed.

I put in the bottom If: echo ("goober"); and it did that too.
__________________
Reply With Quote
  #6  
Old 05-21-2005, 09:26 PM
IcIshoot is offline IcIshoot

Join Date: Mar 2004
Location: Farmington Hills, MI
Posts: 1,473

nvm, I think I fixed that part too...

use if ($view == "main") and if ($view == "search"), etc.

IcI
Reply With Quote
  #7  
Old 05-21-2005, 09:56 PM
atholon is offline atholon
"ath-hole"

Join Date: Jan 2003
Location: Failville.
Posts: 11,357

hmm I thought I tried that.
__________________
Reply With Quote
  #8  
Old 05-21-2005, 09:57 PM
atholon is offline atholon
"ath-hole"

Join Date: Jan 2003
Location: Failville.
Posts: 11,357

NM it be working...thanks.
__________________
Reply With Quote
  #9  
Old 05-21-2005, 11:20 PM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,974

use this... note the ELSEIF statement... extract($_GET); is a simple way of doing

if($HTTP_GET_VARS) foreach($HTTP_GET_VARS as $Key=>$Value) $$Key = $Value;

//code..

extract($_GET,EXTR_SKIP);

If($view=="blah") {
//do blah
} Elseif($view=="blah2") {
//do blah2
} Elseif($view=="blah3") {
//do blah3
} Else {
//do main
}


__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #10  
Old 05-21-2005, 11:43 PM
IcIshoot is offline IcIshoot

Join Date: Mar 2004
Location: Farmington Hills, MI
Posts: 1,473

just curious, which would be better the if...elseif or using switch?
Reply With Quote
  #11  
Old 05-22-2005, 12:01 AM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,974

everyone asks me that but i don't know which is better and why.. i think it's mostly just preference.. i personally like if and elseif
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #12  
Old 05-22-2005, 12:21 AM
JonM is offline JonM
Registered User

Join Date: Jun 2004
Posts: 2,156

i like if and else if, but if i make functions i simply do a switch... don't ask me why...
Reply With Quote
  #13  
Old 05-22-2005, 01:54 PM
atholon is offline atholon
"ath-hole"

Join Date: Jan 2003
Location: Failville.
Posts: 11,357

well now I need to figure out how to redirect the forum variables.
__________________
Reply With Quote
  #14  
Old 05-22-2005, 02:41 PM
IcIshoot is offline IcIshoot

Join Date: Mar 2004
Location: Farmington Hills, MI
Posts: 1,473

redirect the forum variables?

what do you mean?
Reply With Quote
  #15  
Old 05-22-2005, 08:23 PM
JonM is offline JonM
Registered User

Join Date: Jun 2004
Posts: 2,156

i believe if i understand, you could use a $_GET[]; ...
Reply With Quote
  #16  
Old 05-22-2005, 09:53 PM
atholon is offline atholon
"ath-hole"

Join Date: Jan 2003
Location: Failville.
Posts: 11,357

Just part of my old post.

I just need to get a redirect script.

It is simple... if I want the script to search the forum and the tutorial database...

I just need to make it redirect to the search page with the variables in the address bar.
__________________
Reply With Quote
  #17  
Old 05-22-2005, 10:09 PM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,974

use get with hidden fields? like on our map db?
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #18  
Old 05-23-2005, 07:39 AM
atholon is offline atholon
"ath-hole"

Join Date: Jan 2003
Location: Failville.
Posts: 11,357

Well if I am going to use hidden fields in the redirect page how do I use the get part of a form? I am confused.
__________________
Reply With Quote
  #19  
Old 05-23-2005, 07:50 AM
JonM is offline JonM
Registered User

Join Date: Jun 2004
Posts: 2,156

i think it's like this
Code:
<input type="hidden" value="whatever" name="search_property">
Reply With Quote
  #20  
Old 05-23-2005, 07:57 AM
atholon is offline atholon
"ath-hole"

Join Date: Jan 2003
Location: Failville.
Posts: 11,357

Yeah I know that part but how do I get the action so that it does it automattically?
__________________
Reply With Quote
Reply


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

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 On
HTML code is Off

Forum Jump


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




Powered by vBulletin®