YOU ARE BEING REDIRECTED TO THE NEW HIPPIEPIVOT WEBSITE





































Check em out!

 

 [PHP] If...else
NapalM
Posted: Oct 18 2009, 04:06 AM


Unregistered









So lets say if you want to check if something is true or false in php i will show you how to use simple variables and if statements with else conditional statements to error handle and check if it is true or false...

What well be using:
----
Variables: $variablename = the content in the variable;
If Statements: if();
Else Statements: { }else{ }
Make Directory: mkdir('');
----

so lets start ;3


If you want to check if a usersname is correct we will use something like this:
CODE

<?php
$yourname = NapalM;  //the name to check.

$designatedname = NapalM  //The name you want.

if($yourname == designatedname)  //check if your name is the set name.

{  //checking if is correct.

echo " Your name IS ".$designatedname."!"; //if correct name show this.

}else{ //checking for error.

echo " Your name IS NOT ".$designatedname."!"; //if incorrect name show this";

} //ending script.
?>


Now lets say you want to check a name from the url for example: www.mysite.com/index.php?myname=NapalM we use the code variable:

CODE

$catch_name = $_GET['myname'];


and then add it to the script slightly modifying the content.

CODE

<?php
$catch_name = $_GET['myname']; //grabs the content from myname= in url.

$yourname = $catch_name;  //the name to check from inside the URL.

$designatedname = NapalM  //The name you want.

if($yourname == designatedname)  //check if your name is the set name.

{  //checking if is correct.

echo " Your name IS ".$designatedname."!"; //if correct name show this.

}else{ //checking for error.

echo " Your name IS NOT ".$designatedname."!"; //if incorrect name show this";

} //ending script.
?>


But what if your working with directories? its really not that much more work!

CODE

<?php
$dir = uploads/NapalM; //the directory to find.

if (file_exists($dir))  //lets do some checking shall we?

{ //checking if it exists

echo "The file $dir exists"; //state that it does exist.

} else { //check if it does not exist.

echo "The file $dir does not exist"; //state that it does not exists.
   
mkdir(''.$dir,''); //make the directory.

}  //ending script.
?>
PivotElite
Posted: Oct 18 2009, 11:14 AM


The Top Administrato...OF SPAM.
Group Icon

Group: Admin
Posts: 2,028
Member No.: 86
Joined: 31-January 08



Lmao nice tutorial. Although I do not understand half of it. I am not to computer savvy.
NapalM
Posted: Oct 18 2009, 02:01 PM


Unregistered









Ah. i never thought of how hard it is to write tuts for php lol cause its really not that hard but its not that easy to explain.
stickzanimator
Posted: Oct 20 2009, 08:12 PM


3rd member to have 1000 posts!
Group Icon

Group: Moderator
Posts: 1,286
Member No.: 51
Joined: 10-January 08



Nice tut! Very helpful


--------------------
Click here for my youtube page
Respect list:
HippiePivot
Rod
Mustard
Taters
PivotElite
Mantis
R1C
Kittydani
user posted image user posted imageuser posted image
user posted image
Ryan
Posted: Oct 21 2009, 03:51 PM


Legend
*

Group: Regular Member
Posts: 221
Member No.: 181
Joined: 17-March 08



I don't really know what it is for


--------------------
user posted image

Lokis got money

user posted image

//Youtube// //Thread//

Jom
Posted: Nov 2 2009, 12:40 PM


Active User
*

Group: Regular Member
Posts: 82
Member No.: 5,348
Joined: 28-July 09



hey this is pretty cool, i want to learn php but i rly have no knowlage of it... what do u use to code it? o.o action script or something?


--------------------
I <3 Hyun

Hyun> what a waste of a condom jomm >.>
neon-drane> lol
Jomm> lmao ikr
neon-drane> agreed
Hyun> 4 girls in there and you used it on a duck


Topic Options



Hosted for free by InvisionFree (Terms of Use: Updated 7/7/05) | Powered by Invision Power Board v1.3 Final © 2003 IPS, Inc.
Page creation time: 0.0557 seconds | Archive