PHP: executing urls and variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
CreativeForce
Forum Newbie
Posts: 4
Joined: Wed Sep 15, 2004 7:24 am

PHP: executing urls and variables

Post by CreativeForce »

Take a look at this form I could really use some help.

edit patrikG: use

Code: Select all

or

Code: Select all

-tags around code[/color]

This is the form:

<form method="get" name="sw">
<select name="swspecies">
<option value="">Please Select...</option>
<option name="the Ewoks" value="0">the Ewok</option>
<option name="the Wookiee" value="1">the Wookiee</option>
<option name="the Jawa" value="2">the Jawa</option>
<option name="the Mon Calamari" value="3">the Mon Calamari</option>
</select>
<input type"text" name="swcharactername" value="">
<input type="submit" value"Go!">
</form>


This is the PHP:

Code: Select all

$speciewithname_array=array(
0=>"the Ewok",
1=>"the Wookiee",
2=>"the Jawa",
3=>"the Mon Calamarian");
$speciewithoutname_array=array(
0=>"Ewok",
1=>"Wookie",
2=>"Jawa",
3=>"Mon Calamarian");

if(is_array($_post) && count($_post)>1){
if($_post["swcharactername"]!=""){
$speciewithname=$speciewithname_array[$key];}
//what i'm trying to write here is IF swcharactername is NOT blank then I want to extract out your charactername (the name you submitted) and specie for later use. It would maybe be better two makes these two variables into one variable. example: "Creative Force the Ewok". But I don't know how 
elseif($_post["searchtext"]==""){
$speciewithoutname=$speciewithoutname["$key"];}
//what i'm trying to write here is IF swcharactername is blank then charactername is Ewok.
I then want to use the variables i have gathered to open up a window (doesn't matter if it's the same window or a new one):
"http://localhost/starwarsrpgame/characterinfo/($swcharactername + $speciewithname).html or http://localhost/starwarsrpgame/characterinfo/(one variable).html

As you can see from the coding I absolutely know nothing about PHP.

I'm sure you have all written tons of threads explaining this. But I just don't know where to search for them. :(

Thanks
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

can you color this. i go blinde in few seconds! :(
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

OK Several pointers...
$_POST is used if the form uses a POST method
$_GET is used if the form uses a GET method
$_REQUEST checks both.

All are case sensitive (Your form currently uses GET).

To redirect the page you need the command

Code: Select all

header("Location:nextfile_url?getvals");
  exit;
I would recommend you look up the commands header and urlencode in the php manual.
http://www.php.net/manual/en/
Post Reply