|
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. ?>
|
|