Welcome, Guest
Welcome to Makestation! We are a creative arts/indie discussion community — Your center for creative arts discussion, unleashed!

Please note that you must log in to participate in discussions on the forum. If you do not have an account, you can create one here. We hope you enjoy the forum!

Status Updates
Avatar of User
tc4me December 17th, 2024
Blablablabla
Avatar of User
tc4me December 17th, 2024
Blablablabla
Avatar of User
tc4me December 17th, 2024
Blablablabla
Avatar of User
tc4me December 17th, 2024
Blablablabla
Avatar of User
tc4me December 17th, 2024
Blablablabla
View all updates

Search Forums

(Advanced Search)

Forum Statistics
» Members: 923
» Latest member: umiiiii007
» Forum threads: 3,687
» Forum posts: 27,902

Full Statistics

Online Users
There are currently 473 online users.
» 0 Member(s) | 470 Guest(s)
Applebot, Bing, Google

Latest Threads
Is Pakistan Temu Coupon C...
Forum: Announcements
Last Post: umiiiii007
56 minutes ago
» Replies: 0
» Views: 18
Is Philippines Temu Coupo...
Forum: Announcements
Last Post: umiiiii007
57 minutes ago
» Replies: 0
» Views: 19
Is Malaysia Temu Coupon C...
Forum: Announcements
Last Post: umiiiii007
58 minutes ago
» Replies: 0
» Views: 12
Is Thailand Temu Coupon C...
Forum: Announcements
Last Post: umiiiii007
1 hour ago
» Replies: 0
» Views: 16
Is Peru Temu Coupon Code ...
Forum: Announcements
Last Post: umiiiii007
1 hour ago
» Replies: 0
» Views: 17
Is New Zealand Temu Coupo...
Forum: Announcements
Last Post: umiiiii007
1 hour ago
» Replies: 0
» Views: 19
Is Germany Temu Coupon Co...
Forum: Announcements
Last Post: umiiiii007
1 hour ago
» Replies: 0
» Views: 16

 
  Comments
Posted by: Damian B. - August 13th, 2013 at 8:11 PM - Forum: Community Related - Replies (9)

I'm pretty sure there's a problem with the plugin? Or is it custom made?
Because i didn't get a notice although someone did add a comment on my profile.
Thanks!

Print this item

  Learning Graphic & Web Design?
Posted by: 3DWaffle1 - August 13th, 2013 at 5:01 PM - Forum: Photography & Graphics - Replies (2)

How do you learn Graphic & Web Design? Do you go to school for it? What is the best way to learn?

Print this item

  Adobe Master Collection?
Posted by: 3DWaffle1 - August 13th, 2013 at 5:00 PM - Forum: Photography & Graphics - Replies (2)

Do you have Adobe Master Collection? What version do you have? What program do you have install? Which Adobe program do you use most often?

Print this item

  favorite graphics program?
Posted by: 3DWaffle1 - August 13th, 2013 at 5:00 PM - Forum: Photography & Graphics - Replies (4)

What is your favorite graphics program? Do you use it often?

Print this item

  Site Map for MyBB?
Posted by: 3DWaffle1 - August 13th, 2013 at 4:59 PM - Forum: MyBB Related - Replies (2)

Is there a mod for Site Map for MyBB?

Print this item

  PHP - Part 4
Posted by: Darth-Apple - August 13th, 2013 at 4:29 PM - Forum: Software - No Replies

How to Program PHP
Tuturial, part 4

So far, we've explored several fundamental concepts in programming. We've explored the echo statement, and how a PHP file needs to be structured in order for the server to run it. In the second tutorial, an overview was given on how to use variables and arrays. In the third tutorial, functions were introduced. Functions are an extremely fundamental concept in PHP, but it can take quite a while to get used to them. If you're still a little confused, keep reading. All of this will become more clear as you continue working through these tutorials.

In this tutorial, I will introduce the concept of conditional statements. Conditional statements allow us to run different parts of our code, depending on whether a certain condition is met. For example, what if you had a script that denies registration and leaves a message for the user if the user is under 13? Many forums for example are required to deny registration to users under 13 due to COPPA restrictions in US law, so this is a popular real-world example.

Now, you have some code that echoes "sorry, but users must be at least 13 years of age to register," but you need to actually check to see if the user is at least 13 years of age before you execute that code. How exactly would you do that?

PHP has a set of "conditionals" that allow you to check for certain conditions before executing a block of code.

Code:
if ($condition == 1) {
// execute this code
// this IF statement only executes the code in between the curly brackets, and it will only execute this code if the $condition variable is equal to 1.
echo "executing the IF statement code block now. ";
}

The code above won't actually do anything, but it does demonstrate that the code between the curly braces will only execute if the $condition variable is equal to one.

TIP: Notice carefully how there were two equal signs used in the IF statement for ($condition == 1). Why did we need two instead of one? Turns out = and == are different operators in PHP. if you just use =, it will try to set the $condition variable to 1 which obviously is not what we want. If you use ==, instead of trying to assign a value to the variable, it will check its existing value, which is obviously what we want. Generally, you will always use == instead of = in conditionals for PHP.

Now, the code inside of the IF statement will only execute if the $condition variable is equal to 1. What if we want to execute a separate block of code if the $condition variable IS NOT equal to 1? In this case, we'll use an IF statement, and then and ELSE statement.

Code:
if ($condition == 1) {
// execute this code
// this IF statement only executes the code in between the curly brackets, and it will only execute this code if the $condition variable is equal to 1.
echo "executing the IF statement code block now. ";
}
else {
// this ELSE block will ONLY execute if the IF block does not execute. Basically, if $condition is equal to 1, PHP will execute the code inside of the IF block. If $condition is equal to anything OTHER than 1, it will execute the code in the ELSE block instead.
echo "executing ELSE block code now!";

}

As you can see, we've made use of the "else" block above. Simply put, the code in the "else" block will only run if the "if" block fails to run. If $condition is equal to anything other than 1, the else block code will run. If the $condition variable is equal to 1, the "if" block code will run. In no circumstance will both blocks of code ever run together.

So, what if it turns out that you need to execute a block of code if $condition = 1, a separate block of code if $condition = 2, and yet another separate block of code if $condition is equal to anything else? Turns out PHP has the "IF ELSE" block for that.


Code:
if ($condition == 1) {
// execute this code
// this IF statement only executes the code in between the curly brackets, and it will only execute this code if the $condition variable is equal to 1.
echo "choice 1 has been selected! ";
}
if else ($condition == 2) {
// this block of code ONLY executes if the $condition variable is equal to 2.
echo "choice 2 has been selected! ";

}
else {
// this ELSE block will ONLY execute if the IF block does not execute. Basically, if $condition is equal to 1, PHP will execute the code inside of the IF block. If $condition is equal to anything OTHER than 1, it will execute the code in the ELSE block instead.
echo "Oops! We don't recognize your choice selection. An error has occurred. ";

}

As you can see, the first IF block only executes if $condition is equal to 1. The second "IF ELSE" block only executes if $condition is equal to 2. The last "ELSE" block only executes if neither of the previous two blocks of code executed. In other words, "ELSE" executes if your network of IF and IF else statements never "found a match".

There are actually other conditional statements in PHP as well. The "switch" statement is fairly popular, and there are try and catch statements as well. These aren't very important to the purpose of our tutorials and aren't essential to learning the basics of PHP, so we won't attempt to go over these in detail.

Anyway, back to the original script concept for denying user registration to users under thirteen...

Code:
if ($age < 13) {
echo "Sorry, but users must be at least 13 years of age to register. ";
// the < operator is the "less than" operator for PHP.
}
else {
processRegistration (); // runs a function that processes the user registration.
// This only runs if the user is 13 or over. If the user was under 13, the IF block above would have run instead of this block of code. Remember, in no circumstance will the "ELSE" block ever run if the IF block has run.
}

If you would like to play around with these scripts, copy and paste the code below and give it a try. Big Grin

Code:
<?php
// play around with the following variable
$age = 12;
if ($age < 13) {
echo "Sorry, but users must be at least 13 years of age to register. ";
// the < operator is the "less than" operator for PHP.
}
else {
processRegistration (); // runs a function that processes the user registration.
// This only runs if the user is 13 or over. If the user was under 13, the IF block above would have run instead of this block of code. Remember, in no circumstance will the "ELSE" block ever run if the IF block has run.
}
?>

In the next tutorial, we will explore how HTML forms are set up and how we can design the first interactive applications. The fun stuff will be beginning soon. Big Grin

Stay tuned!

Next Tutorial: Let the fun stuff begin; forms and PHP introduction
Directory of PHP Tutorials

Print this item

  Nearforum (General forum)
Posted by: Tyler - August 13th, 2013 at 5:22 AM - Forum: Other Communites & Promotion - Replies (11)

Nearforum is a general forum so it contains a lot, a lot of places to post on hopefully satisfying everyone! This is my first time making a forums, so give me a break Tongue But we currently have 19 members and almost 90 posts! Darth-Apple uses it and he seems to enjoy it ^_^ So give it a go please!

Link: http://nearforum.com/index.php

Print this item

  What are your goals
Posted by: Tyler - August 13th, 2013 at 5:19 AM - Forum: General Discussion - Replies (3)

What are your goals for your websites, forums, blogs ect?

I'd love to hit 50 members and than 100, I think 100 people is still a good amount even though some of these forums hit thousands, I'd be happy with 100. I'd also like to hit 1,000 posts. (my goals for now) if my forums is successful I'd love to hit 1,000 members and 100k posts. I'd also like to learn more on how to make my forums better (as this was my first time making a forums)

Print this item

  50 Members
Posted by: Gmdykfuiygh66476 - August 13th, 2013 at 4:23 AM - Forum: Announcements - Replies (17)

As of this post, we're 3 members away from 50, a very important milestone. This site has grown so fast and is so active, and it's great being a part of it Smile

Print this item

  Doctor Who
Posted by: Gmdykfuiygh66476 - August 13th, 2013 at 4:18 AM - Forum: Media & Entertainment - Replies (13)

So, Matt Smith, the Eleventh Doctor, is leaving. He played the role for three years. I personally admired how he managed to make himself seem much older than he really is, being even younger than the tenth one, David Tennant. Also, I just loved the bowtie Tongue

But I'm excited because a great candidate is taking his place, Peter Capaldi. My favorite thing about him is that he's over 40 years old. Honestly the people who are all upset that Tennant wasn't brought back and they're using some "old guy" instead get on my nerves. They say they won't be watching anymore - I certainly won't miss them Tongue

Any other Doctor Who fans here?

Print this item


Dark/Light Theme Selector

Contact Us | Makestation | Return to Top | Lite (Archive) Mode | RSS Syndication 
Proudly powered by MyBB 1.8, © 2002-2024
Forum design by Makestation Team © 2013-2024