You are not logged in.

#1 12 Jan 2007 3:52 pm

Butcher
Moderator
From: Norway
Registered: Jul 2006
Posts: 308

How does the "Elseif" statement work?

Hi again, I am trying to get the "simple" PHP statement, "Elseif" otherwise known as "if else" to work on my radiobuttons on my site.

I have 2 radiobuttons here: http://www.bamboocommandos.com/bc_data/sql.php/, and I want the "No" one to have a special function. When its selected and you press submit, I want it to redirect you to a completely other site than it normally would.

I have been told that using the "if else" statement, I can do that. But I dont know how to connect it to my input form (I tried googling it in a load of variables, but none gave a decent answer).

Right now, it says:

Code:

<td width="175" align="left" valign="middle">
&nbsp;<input type="radio" name = "ban_true" cols="43"> Yes
<input type="radio" name == "ban_true>    
<br>
<br>
&nbsp;<input type="radio" name = "ban_false" cols="43"> No</td>
<?php
if ($input type="radio" name == "ban_true")
echo "The statement was evaluated to true";
elseif ($input type="radio" name == "ban_false")
echo "The statement was evaluated to false";
else
echo "The statement was evaluated to false";
?>

I will of course have it use a redirect rather than a echo, but this obviously didn't work. Dont think I really understood how to ingrate this correctly.


http://bamboocommandos.com/butcher_img/butchersig7.jpg

Offline

 

#2 12 Jan 2007 5:10 pm

MadHatter
Administrator
From: Dallas TX
Registered: Jun 2006
Posts: 529
Website

Re: How does the "Elseif" statement work?

I never use the elseif statement because it has subtle differences as to how its used, and comming from a C background (and not a pascal background) 

Code:

else if (condition) { 
    ... 
}

looks better than:

Code:

if(condition):
    ...
endif

and thats the type of syntax used w/ elseif (condition): ... endif.



if you have multiple things you're trying to test, you need an and (written &&) or an or (written ||) in there to tell it how those multiple tests work together:

Code:

<?php
if($type == "radio" && $name == "ban_true") {
    echo "The statement was eval'd to true";
}else if($type == "radio" && $name == "ban_false") {
    echo "The statement was eval'd to false";
}else {
    echo "something else happened";
}

also, form elements are stored in a variable named $_POST['whatever_the_name_attribute_was'] and under some instances are broken out into variables named $whatever_the_name_attribute_was, so if thats what you were trying to test, then thats how you do it.

if you're taking an input and trying to test its value, you should probably write it like:


Code:

<input name="one" type="text" />
<?php
if(isset($_POST['one']) && $_POST['one'] == "whatever") {
    // do whatever you need to do here
}
?>

the isset method will determine whether the input from the form was 1. present, and 2. filled out.

if

Code:

isset($_POST['one'])

evaluated false, then it would skip the

Code:

$_POST['one'] == "whatever"

statements are evaluated left to right, if isset($_POST['one']) was false, then the second condition cannot make the overall statement true (false && true is false, false && false is false, only true && true will allow that if statement to execute) since we used an and condition.  if we used an || (or) then it would test the second condition if the first was false because

if false or true = true
if true or false = true

because it only needs one condition to be true (ands require all conditions joined w/ an and clause be true).

Offline

 

#3 12 Jan 2007 5:30 pm

Butcher
Moderator
From: Norway
Registered: Jul 2006
Posts: 308

Re: How does the "Elseif" statement work?

I am now trying with:

Code:

<td width="85" align="left" valign="middle">Ban:</td>
    <td width="175" align="left" valign="middle">
    <input type="radio" name = "ban_true" value="true" cols="43"> Yes
    <br>
    <input type="radio" name = "ban_false" value="false" cols="43"> No
    <?php
if($type == "radio" && $name == "ban_true") {
    echo "Person is permanently banned";
}else if($type == "radio" && $name == "ban_false") {
    echo "Person is not permanently banned";
}else {
    echo "An error occured";
}
?>
</td>

Not sure what to set the values to, and do I need a database table section line for both true and false?

$_POST is just used to output it, isnt it? And am I perhaps making this harder than it should be, all I need basically is to have it redirect the person submitting to another page instead of the original one if he or she submits it with the "No" option.

Also, I can choose both "Yes" and "No" O_o, never tought making a form would be that hard, lol.


http://bamboocommandos.com/butcher_img/butchersig7.jpg

Offline

 

#4 12 Jan 2007 5:59 pm

MadHatter
Administrator
From: Dallas TX
Registered: Jun 2006
Posts: 529
Website

Re: How does the "Elseif" statement work?

ok, for that, you need to test it like this:

Code:

<?php
// if we've posted to this page, this will be set, otherwise it wont, and we'll display the html below in the else block
if(isset($_POST['ban'])) { 
    if($_POST['ban'] == "true") {  // if the Banned radio button was selected this will be "true"
        echo "true";    
    }else if($_POST['ban'] == "false") { // if the UnBanned radio button was selected this will be "false"
        echo "false";
    }else {
        echo "not set";
    }
}else {
?>
<html>
<head>
</head>
<body>
<form action="test.php" method="POST">
<label><input type="radio" name="ban" value="true"/> Banned?</label><br />
<label><input type="radio" name="ban" value="false" checked="checked"/> Unbanned</label><br />
<input type="submit" value="submit"/>
</form>
</body>
</html>
<?php
}
?>

you dont need 2 radio buttons with different names.  its a single selection input type, so name them both the same, and the value of that element will be the "value" of whatever one was selected.

Offline

 

#5 13 Jan 2007 3:40 am

Butcher
Moderator
From: Norway
Registered: Jul 2006
Posts: 308

Re: How does the "Elseif" statement work?

Ok, think I got it working now:

Code:

<input name="ban" type="radio" id="true"><label for="true">Yes</label>
<br>
<input name="ban" type="radio" id="false" checked="checked"><label for="false">No</label>
<br>
<?php
// if we've posted to this page, this will be set, otherwise it wont, and we'll display the html below in the else block
if(isset($_POST['ban'])) { 
    if($_POST['ban'] == "true")  // if the Banned radio button was selected this will be "true"
       echo "true"; 
    }else if($_POST['ban'] == "false") // if the UnBanned radio button was selected this will be "false"
       header( 'Location: http://www.bamboocommandos.com/index.php' ) ;
?>

This should work with the form already on the page I think, and redirect if submitted with "No".

Cant input forms contain dropdown menus? Made one for the maps, but when trying to add the "input type=" line in dreamweaver, there wasnt a option to have the dropdown menu or <select> anywhere.

Also made a process.php, which I think will send the information to my database big_smile


http://bamboocommandos.com/butcher_img/butchersig7.jpg

Offline

 

#6 13 Jan 2007 11:12 am

MadHatter
Administrator
From: Dallas TX
Registered: Jun 2006
Posts: 529
Website

Re: How does the "Elseif" statement work?

all form elements will be available (assumming the method was set to post) in the $_POST variable.  one thing you can do to see this, is to create a form (make sure to give all of your form elements name="some unique name") and where it posts to, do

Code:

print_r($_POST);

it will display each item in the array, its index (or index name) and the value of that field.

so in the example I posted, it will show:

Code:

Array( [bar] => true );

if the yes is selected, and false if the no was selected.  when you do a drop down list, it's value will be the selected item.

Offline

 

#7 13 Jan 2007 12:23 pm

Butcher
Moderator
From: Norway
Registered: Jul 2006
Posts: 308

Re: How does the "Elseif" statement work?

Ok, think I got it:

Code:

    <select name="map">
    <option value="dp"><label for="dp">Dalian Plant</label></option>
    <option value="do"><label for="do">Daqing Oilfields</label></option>
    <option value="dv" selected="selected"><label for="dv">Dragon Valley</label></option>
    <option value="fp"><label for="fp">FuShe Pass</label></option>
    <option value="go"><label for="go">Gulf of Oman</label></option>
    <option value="kd"><label for="kd">Kubra Dam</label></option>
    <option value="mc"><label for="mc">Mashtuur City</label></option>
    <option value="ocs"><label for="ocs">Operation Clean Sweep</label></option>
    <option value="rj"><label for="rj">Road to Jalalabad</label></option>
    <option value="sp"><label for="sp">Sharqi Peninsula</label></option>
    <option value="st"><label for="st">Songhua Stalemate</label></option>
    <option value="sk"><label for="sk">Strike at Karkand</label></option>
    <option value="zw"><label for="zw">Zatar Wetlands</label></option>
    </select>
    <br>
    <?php
if(isset($_POST['map'])) { 
    if($_POST['map'] == "dp")
       echo "Map Submitted"; 
    }else if($_POST['map'] == "do")
    echo "Map Submitted"; 
    }else if($_POST['map'] == "dv")
    echo "Map Submitted"; 
    }else if($_POST['map'] == "fp")
    echo "Map Submitted"; 
    }else if($_POST['map'] == "go")
    echo "Map Submitted"; 
    }else if($_POST['map'] == "kd")
    echo "Map Submitted"; 
    }else if($_POST['map'] == "mc")
    echo "Map Submitted"; 
    }else if($_POST['map'] == "ocs")
    echo "Map Submitted"; 
    }else if($_POST['map'] == "rj")
    echo "Map Submitted"; 
    }else if($_POST['map'] == "sp")
    echo "Map Submitted"; 
    }else if($_POST['map'] == "st")
    echo "Map Submitted"; 
    }else if($_POST['map'] == "sk")
    echo "Map Submitted"; 
    }else if($_POST['map'] == "zw")
       header( 'Location: http://www.bamboocommandos.com/index.php' ) ;
?>

That should post the map choice to the database I hope... Quite unsure about this once, think I screwed something up but not sure what.


http://bamboocommandos.com/butcher_img/butchersig7.jpg

Offline

 

#8 13 Jan 2007 12:39 pm

MadHatter
Administrator
From: Dallas TX
Registered: Jun 2006
Posts: 529
Website

Re: How does the "Elseif" statement work?

there is an easier flow control to use other than if else.  the switch statement does the same thing but is a lot easier to write:

Code:

<select name="map">
    <option value="dp"><label for="dp">Dalian Plant</label></option>
    <option value="do"><label for="do">Daqing Oilfields</label></option>
    <option value="dv" selected="selected"><label for="dv">Dragon Valley</label></option>
    <option value="fp"><label for="fp">FuShe Pass</label></option>
    <option value="go"><label for="go">Gulf of Oman</label></option>
    <option value="kd"><label for="kd">Kubra Dam</label></option>
    <option value="mc"><label for="mc">Mashtuur City</label></option>
    <option value="ocs"><label for="ocs">Operation Clean Sweep</label></option>
    <option value="rj"><label for="rj">Road to Jalalabad</label></option>
    <option value="sp"><label for="sp">Sharqi Peninsula</label></option>
    <option value="st"><label for="st">Songhua Stalemate</label></option>
    <option value="sk"><label for="sk">Strike at Karkand</label></option>
    <option value="zw"><label for="zw">Zatar Wetlands</label></option>
    </select>
    <br>
    <?php
if(isset($_POST['map'])) { 
    switch($_POST['map']) }
    case "dp":
        echo "Map Submitted"; 
        break;
    case "do":
        echo "Map Submitted"; 
        break;
    case "dv":
        echo "Map Submitted"; 
        break;
    case "fp":
        echo "Map Submitted"; 
        break;
    case "go":
        echo "Map Submitted"; 
        break;
    case "kd":
        echo "Map Submitted"; 
        break;
    case "mc":
        echo "Map Submitted"; 
        break;
    case "ocs":
        echo "Map Submitted"; 
        break;
    case "rj":
        echo "Map Submitted";
        break; 
    case "sp":
        echo "Map Submitted"; 
        break;
    case "st":
        echo "Map Submitted"; 
        break;
    case "sk":
        echo "Map Submitted"; 
        break;
    case "zw":
    default:
        header( 'Location: http://www.bamboocommandos.com/index.php' ) ;
        break;        
?>

the switch statement will compare a single statement

Code:

switch($on_this_value) {
    case "value 1": // if $on_this_value == "value 1" 
        // executable code
        break; // <- if you dont add this, it will fall through the list 
               //    until it reaches a "break" or it falls through all the cases
}

and if all you're planning on doing is echo'ing "Map Submitted" after every one (and not running some custom code after each depending on what its value was), then you can shorten it all up quite a bit by doing this:

Code:

<select name="map">
    <option value="dp"><label for="dp">Dalian Plant</label></option>
    <option value="do"><label for="do">Daqing Oilfields</label></option>
    <option value="dv" selected="selected"><label for="dv">Dragon Valley</label></option>
    <option value="fp"><label for="fp">FuShe Pass</label></option>
    <option value="go"><label for="go">Gulf of Oman</label></option>
    <option value="kd"><label for="kd">Kubra Dam</label></option>
    <option value="mc"><label for="mc">Mashtuur City</label></option>
    <option value="ocs"><label for="ocs">Operation Clean Sweep</label></option>
    <option value="rj"><label for="rj">Road to Jalalabad</label></option>
    <option value="sp"><label for="sp">Sharqi Peninsula</label></option>
    <option value="st"><label for="st">Songhua Stalemate</label></option>
    <option value="sk"><label for="sk">Strike at Karkand</label></option>
    <option value="zw"><label for="zw">Zatar Wetlands</label></option>
    </select>
    <br>
    <?php
if(isset($_POST['map'])) { 
    switch($_POST['map']) }
    case "dp":
    case "do":
    case "dv":
    case "fp":
    case "go":
    case "kd":
    case "mc":
    case "ocs":
    case "rj":
    case "sp":
    case "st":
    case "sk":
        echo "Map Submitted"; 
        break;
    case "zw":
    default:
        header( 'Location: http://www.bamboocommandos.com/index.php' ) ;
        break;        
?>

and it will execute the code for case "sk" for every case except if the value of map isn't listed there (which is what the default: case handles), or the value of $_POST['map'] is "zw".



style wise, I like to wrap my case statements in braces like this:

Code:

switch($value) {
    case 32: {
        // executable code here
    } break;
}

because adding the braces scopes the code.  meaning if I declare a variable inside that case statement, and forget to add a break, its value can not be accidentally overwritten by another case statement.  in .NET if you declare a variable inside the case statement, and try to declare a variable of the same name in another case block, it will throw a compiler error saying you've already declared a variable inside that switch statement, unless you add the braces.

Offline

 

#9 13 Jan 2007 3:33 pm

Butcher
Moderator
From: Norway
Registered: Jul 2006
Posts: 308

Re: How does the "Elseif" statement work?

Weird, get a parse error on it.

Code:

Parse error: syntax error, unexpected '}', expecting ':' or '{' in /home/bambooco/public_html/bc_data/sql.php on line 54

Line 54: switch($_POST['map']) }

And if I remove the } from it, I get:

Code:

Parse error: syntax error, unexpected T_CASE, expecting ':' or '{' in /home/bambooco/public_html/bc_data/sql.php on line 55

Line 55: case "dp":

Dont think the site likes brackets... Weird.

Last edited by Butcher (13 Jan 2007 3:34 pm)


http://bamboocommandos.com/butcher_img/butchersig7.jpg

Offline

 

#10 13 Jan 2007 3:49 pm

MadHatter
Administrator
From: Dallas TX
Registered: Jun 2006
Posts: 529
Website

Re: How does the "Elseif" statement work?

oh, fix the switch line to (my bracket was backwards):

switch($_POST['map']) {

Offline

 

#11 14 Jan 2007 4:26 am

Butcher
Moderator
From: Norway
Registered: Jul 2006
Posts: 308

Re: How does the "Elseif" statement work?

Hmm, I switched the direction of it, but I still get the same error:

Code:

Parse error: syntax error, unexpected T_CASE, expecting ':' or '{' in /home/bambooco/public_html/bc_data/sql.php on line 55

Line 55: case "dp":

http://bamboocommandos.com/butcher_img/butchersig7.jpg

Offline

 

#12 14 Jan 2007 9:23 am

MadHatter
Administrator
From: Dallas TX
Registered: Jun 2006
Posts: 529
Website

Re: How does the "Elseif" statement work?

post your code again.

Offline

 

#13 15 Jan 2007 7:27 am

Butcher
Moderator
From: Norway
Registered: Jul 2006
Posts: 308

Re: How does the "Elseif" statement work?

Code:

<td width="85" align="left" valign="middle">Map:</td>
    <td width="175" align="left" valign="middle">
    <select name="map">
    <option value="dp"><label for="dp">Dalian Plant</label></option>
    <option value="do"><label for="do">Daqing Oilfields</label></option>
    <option value="dv" selected="selected"><label for="dv">Dragon Valley</label></option>
    <option value="fp"><label for="fp">FuShe Pass</label></option>
    <option value="go"><label for="go">Gulf of Oman</label></option>
    <option value="kd"><label for="kd">Kubra Dam</label></option>
    <option value="mc"><label for="mc">Mashtuur City</label></option>
    <option value="ocs"><label for="ocs">Operation Clean Sweep</label></option>
    <option value="rj"><label for="rj">Road to Jalalabad</label></option>
    <option value="sp"><label for="sp">Sharqi Peninsula</label></option>
    <option value="st"><label for="st">Songhua Stalemate</label></option>
    <option value="sk"><label for="sk">Strike at Karkand</label></option>
    <option value="zw"><label for="zw">Zatar Wetlands</label></option>
    <option value="cr"><label for="cr">Can't Remember</label></option>
    </select>
    <br>
    <?php
if(isset($_POST['map'])) {
    switch($_POST['map']) 
    case "dp":
    case "do":
    case "dv":
    case "fp":
    case "go":
    case "kd";
    case "mc";
    case "ocs";
    case "rj":
    case "sp":
    case "st":
    case "sk":
    case "zw":
        echo "Map Submitted"; 
        break;
    case "cr":
    default:
        header( 'Location: http://www.bamboocommandos.com/index.php' ) ;
        break;        
?>

http://bamboocommandos.com/butcher_img/butchersig7.jpg

Offline

 

#14 15 Jan 2007 7:38 am

MadHatter
Administrator
From: Dallas TX
Registered: Jun 2006
Posts: 529
Website

Re: How does the "Elseif" statement work?

Butcher :

switch($_POST['map'])

you need to add a { after the switch statement.  like this:

Code:

switch($_POST['map']) {

you have one after your if statement, but not after the switch statement.

Offline

 

#15 15 Jan 2007 9:21 am

Butcher
Moderator
From: Norway
Registered: Jul 2006
Posts: 308

Re: How does the "Elseif" statement work?

Well I'll be damned, I get this:

Code:

Parse error: syntax error, unexpected $end in /home/bambooco/public_html/bc_data/sql.php on line 155

And line 155 is: </html>, how the hell can the command to end the html statement be wrong?!


http://bamboocommandos.com/butcher_img/butchersig7.jpg

Offline

 

#16 15 Jan 2007 10:16 am

MadHatter
Administrator
From: Dallas TX
Registered: Jun 2006
Posts: 529
Website

Re: How does the "Elseif" statement work?

whats at line 154 (or the first line above 155)?

Offline

 

#17 15 Jan 2007 10:42 am

AmbassadorKosh
Experienced Member
From: Ukraine, Kiev
Registered: Nov 2006
Posts: 18
Website

Re: How does the "Elseif" statement work?

Code:

    case "mc";
    case "ocs";

Offline

 

#18 15 Jan 2007 11:10 am

MadHatter
Administrator
From: Dallas TX
Registered: Jun 2006
Posts: 529
Website

Re: How does the "Elseif" statement work?

yep, missed that (my monitor at home sucks, so its hard to tell the difference between a colon and a semicolon).  you have to use : not ; on kd, mc, and ocs cases.

also, you need beginning and ending braces you don't have any on the end either, so make sure you have that too.

Code:

switch($on) {
    case ...
}

Offline

 

#19 15 Jan 2007 1:09 pm

Butcher
Moderator
From: Norway
Registered: Jul 2006
Posts: 308

Re: How does the "Elseif" statement work?

Ok, changed it to:

Code:

<td width="85" align="left" valign="middle">Map:</td>
    <td width="175" align="left" valign="middle">
    <select name="map">
    <option value="dp"><label for="dp">Dalian Plant</label></option>
    <option value="do"><label for="do">Daqing Oilfields</label></option>
    <option value="dv" selected="selected"><label for="dv">Dragon Valley</label></option>
    <option value="fp"><label for="fp">FuShe Pass</label></option>
    <option value="go"><label for="go">Gulf of Oman</label></option>
    <option value="kd"><label for="kd">Kubra Dam</label></option>
    <option value="mc"><label for="mc">Mashtuur City</label></option>
    <option value="ocs"><label for="ocs">Operation Clean Sweep</label></option>
    <option value="rj"><label for="rj">Road to Jalalabad</label></option>
    <option value="sp"><label for="sp">Sharqi Peninsula</label></option>
    <option value="st"><label for="st">Songhua Stalemate</label></option>
    <option value="sk"><label for="sk">Strike at Karkand</label></option>
    <option value="zw"><label for="zw">Zatar Wetlands</label></option>
    <option value="cr"><label for="cr">Can't Remember</label></option>
    </select>
    <br>
    <?php
if(isset($_POST['map'])) {
    switch($_POST['map']) {
    case "dp":
    case "do":
    case "dv":
    case "fp":
    case "go":
    case "kd":
    case "mc":
    case "ocs":
    case "rj":
    case "sp":
    case "st":
    case "sk":
    case "zw":
        echo "Map Submitted";
        }
        break;
    case "cr":
    default:
        header( 'Location: http://www.bamboocommandos.com/index.php' ) ;
        break;        
?>

Now I get this error code:

Code:

Parse error: syntax error, unexpected T_CASE in /home/bambooco/public_html/bc_data/sql.php on line 71

Line 69:       }
Line 70:         break;
Line 71:     case "cr":
Line 72:     default:
Line 73:         header( 'Location: http://www.bamboocommandos.com/index.php' ) ;
Line 74:         break;       
Line 75: ?>

Dont see how he can find anything wrong there.


http://bamboocommandos.com/butcher_img/butchersig7.jpg

Offline

 

#20 15 Jan 2007 1:18 pm

MadHatter
Administrator
From: Dallas TX
Registered: Jun 2006
Posts: 529
Website

Re: How does the "Elseif" statement work?

remove line 69, add it after line 74.

Offline

 

#21 16 Jan 2007 8:40 am

Butcher
Moderator
From: Norway
Registered: Jul 2006
Posts: 308

Re: How does the "Elseif" statement work?

He still finds an error with </html> after I fixed that, weird.


http://bamboocommandos.com/butcher_img/butchersig7.jpg

Offline

 

#22 16 Jan 2007 9:51 am

MadHatter
Administrator
From: Dallas TX
Registered: Jun 2006
Posts: 529
Website

Re: How does the "Elseif" statement work?

post the whole thing, <html> to </html>

Offline

 

#23 16 Jan 2007 12:03 pm

Butcher
Moderator
From: Norway
Registered: Jul 2006
Posts: 308

Re: How does the "Elseif" statement work?

Ok, here she be:

Code:

<html>
<head>
<title>SQL TESTING</title>
</head>
<body bgcolor="#E8E8E8">

<table width="900" border="0" align="center">
  <tr>
    <td align="center"><h1>Ban submission form</h1></td>
  </tr>
  <tr>
    <td align="center">&nbsp;</td>
  </tr>
  <tr>
    <td><table width="100%" border="0" align="center">
  <tr>
    <td colspan="3" align="center" valign="middle"> 
</td>
  </tr>
  <form action="process.php" method="post">
  <tr>
    <td width="85" align="left" valign="middle"><strong>Input Name</strong></td>
    <td align="left" valign="middle"><strong>Input</strong></td>
    <td align="left" valign="middle"><strong>Explanation</strong></td>
  </tr>
  <tr>
  
    <td width="85" align="left" valign="middle">Name:</td>
    <td width="175" align="left" valign="middle">&nbsp;<input type="text" name="name" cols="43" maxlength="20"></td>
    <td width="388" align="left" valign="middle">Exact in-game name the player you banned</td>
  </tr>
  <tr>
    <td width="85" align="left" valign="middle">Map:</td>
    <td width="175" align="left" valign="middle">
    <select name="map">
    <option value="dp"><label for="dp">Dalian Plant</label></option>
    <option value="do"><label for="do">Daqing Oilfields</label></option>
    <option value="dv" selected="selected"><label for="dv">Dragon Valley</label></option>
    <option value="fp"><label for="fp">FuShe Pass</label></option>
    <option value="go"><label for="go">Gulf of Oman</label></option>
    <option value="kd"><label for="kd">Kubra Dam</label></option>
    <option value="mc"><label for="mc">Mashtuur City</label></option>
    <option value="ocs"><label for="ocs">Operation Clean Sweep</label></option>
    <option value="rj"><label for="rj">Road to Jalalabad</label></option>
    <option value="sp"><label for="sp">Sharqi Peninsula</label></option>
    <option value="st"><label for="st">Songhua Stalemate</label></option>
    <option value="sk"><label for="sk">Strike at Karkand</label></option>
    <option value="zw"><label for="zw">Zatar Wetlands</label></option>
    <option value="cr"><label for="cr">Can't Remember</label></option>
    </select>
    <br>
    <?php
if(isset($_POST['map'])) {
    switch($_POST['map']) {
    case "dp":
    case "do":
    case "dv":
    case "fp":
    case "go":
    case "kd":
    case "mc":
    case "ocs":
    case "rj":
    case "sp":
    case "st":
    case "sk":
    case "zw":
        echo "Map Submitted";
        break;
    case "cr":
    default:
        header( 'Location: http://www.bamboocommandos.com/index.php' ) ;
        break;   
        }     
?>
    </td>
    <td width="388" align="left" valign="middle">Map you banned him or her on</td>
  </tr>
  <tr>
    <td width="85" height="200" align="left" valign="middle">Reason:</td>
    <td width="175" align="left" valign="middle">&nbsp;<input type="textarea" name = "reason" rows="10" cols="40"></td>
    <td width="388" align="left" valign="middle">Reason for the ban, maximum 500 characters
    <br>
    <br>
    Please keep the reason very specific and objective, mention the exact rules the person broke and how he or she did it
    </td>
  </tr>
  <tr>
    <td width="85" align="left" valign="middle">Ban:</td>
    <td width="175" align="left" valign="middle">
<input name="ban" type="radio" id="true"><label for="true">Yes</label>
<br>
<input name="ban" type="radio" id="false" checked="checked"><label for="false">No</label>
<br>
<?php
// if we've posted to this page, this will be set, otherwise it wont, and we'll display the html below in the else block
if(isset($_POST['ban'])) { 
    if($_POST['ban'] == "true")  // if the Banned radio button was selected this will be "true"
       echo "true"; 
    }else if($_POST['ban'] == "false") // if the UnBanned radio button was selected this will be "false"
       header( 'Location: http://www.bamboocommandos.com/index.php' ) ;
?>
</td>
    <td width="388" align="left" valign="middle">Is the person permanently banned or not</td>
  </tr>
  <tr>
    <td width="85" align="left" valign="middle">Date:</td>
    <td width="175" align="left" valign="middle">&nbsp;<input type="text" name = "date" cols="43" maxlength="8"></td>
    <td width="388" align="left" valign="middle">The date of the ban, in this format: Year.Month.Day (Example: 
      <?php
echo date("Y.m.d");
?>)
</td>
  </tr>
  <tr>
    <td colspan="3" align="center" valign="middle">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="3" align="center" valign="middle">
    <input name="Submit" type="submit" id="Submit" value="Submit">
    &nbsp;&nbsp;&nbsp;&nbsp;
    <input name="Reset" type="reset" id="Reset2" value="Reset"> 
    </td>
  </tr>
  </form>
  <tr>
    <td colspan="3" align="center" valign="middle">
    
    </td>
  </tr>
</table>
</td>
  </tr>
  <tr>
    <td align="center">Date: 
    <?php
echo date("d");
?>
th of 
<?php
echo date("F");
?> 
(<?php
echo date("l");
?>), <?php
echo date("Y");
?>
</td>
  </tr>
  <tr>
    <td align="center">Make sure all the information you submitted is correct, check it for typos or errors before you press submit!</td>
  </tr>
</table>

</body>
</html>

I think HTML hates me, hehe.


http://bamboocommandos.com/butcher_img/butchersig7.jpg

Offline

 

#24 17 Jan 2007 5:56 am

AmbassadorKosh
Experienced Member
From: Ukraine, Kiev
Registered: Nov 2006
Posts: 18
Website

Re: How does the "Elseif" statement work?

line53: if(isset($_POST['map'])) {
line54:    switch($_POST['map']) {
...
line 74:  }
line 75:}

Offline

 

#25 18 Jan 2007 1:51 pm

Butcher
Moderator
From: Norway
Registered: Jul 2006
Posts: 308

Re: How does the "Elseif" statement work?

Seems to work, just need to finish the SQL connections, and I can test it all big_smile


http://bamboocommandos.com/butcher_img/butchersig7.jpg

Offline

 



© 2003 - 2019 NullFX
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License