User Tag List

Results 1 to 1 of 1

Thread: Expire's [TUTS] N0.2. How to start work with web developing language [PHP] and [MySQL] Database

  1. #1
    Moderator <span style='color: #FF1493'><span class='glow_000000'>Vitrex</span></span>'s Avatar

    Join Date
    Sep 2013
    United Kingdom
    Thanked 134 Times in 94 Posts

    Expire's [TUTS] N0.2. How to start work with web developing language [PHP] and [MySQL] Database

    In my first "tut" you saw how to make variables and output them in simplest ways.
    Now we gonna talk about why the ***** we need them and what we can make with them and HTML form.
    All tutorial will be inside CODE.

    Okay guys now just look at the code and follow the comments it will be easier for you and me of course :)
    how you already see we will be talking about saving info to variables and do "things" with them.
    // Create the variable named $url to grab all data from website address bar and check our stage in form with super global $_GET
    $url = isset($_GET['stage']) ? $_GET['stage'] : null; 
    if(isset($_GET['stage'])) { // check if the our stage set in this case it will be 2
    echo "We are at stage 2 <br />"; // output simple text that tells us that we are at stage 2
    echo "<a href = 'tutorial.php'>Go back to stage One</a>"; // making link to go back to stage 1
    if(isset($_POST['submit'])) { // check if the button submit was pressed 
    //echo "Your name is : " .$_POST['name']; // output the info from input name with super global $_POST
    //echo "Your age : ". $_POST['age']; // do the same for the age
    You can output your form info like that but think if we need to save our value and use it many times or just do simple 
    calculating it becomes more complicated, that why we use variable to save our info there is two ways to do that I will show now both of them.
    /* The first one will be
    $name = $_POST['name'];
    $age = $_POST['age'];
    Output them will look like that 
    echo "Your name is : $name and you $age years old !";
    /* The second way
    Making array for that 
    $inputValues = Array('name' => ''.$_POST['name'].'', age = $_POST['age'],);
    Now to output them we have to call our array values.
    echo "Your name is : {$inputValues[name]} and you : {$inputValues['age'] Years old !}";
    // In both ways we will have the same output, I prefer use array with much more inputs for example like 10 15 and more, it's more comfortable FOR ME.
    // Choose your way to do that.
    Now what we can do with our variables? answer is simple ANYTHING !
    Make simple calculation for age.
    $ageMultiplier = 4 Creating new variable with integer value 4
    I'll show how to do that in both ways for your saved variables.
    echo "Your name is : $name and you $age years old ! After $ageMultiplier years you will be : " . $age + $ageMultiplier . " Years old ";
    echo "Your name is : {$inputValues['name']} and you {$inputValues['age']} years old ! After $ageMultiplier years you will be : " . $inputValues['age'] + $ageMultiplier . " Years old ";
    In both ways we get the same output, again it depends on which one you feel more comfortable.
    } else {
    	<form action = 'tutorial.php?stage=2' method = 'POST'>
    	<input type = 'text' name = 'name' placeholder = 'Enter your name here' />
    	<input type = 'text' name = 'age' placeholder = 'Enter your age here' />
    	<input type = 'submit' name = 'submit' value = 'submit'/>
    <?php } ?>
    This is the simplest way to manipulate with HTML forms.
    In next tutorial i'll show you how to make simple register and login system with sessions. :)
    Hope you enjoy!
    Last edited by Vitrex; 08-22-2014 at 09:36 PM.
    Shopper Got a Sticky! 1 year registered Member Level XL Level C
    Raffle Winner Donator Member of Staff
    I won't create anything for you, i can only guide you to right direction.
    Don't forget to read rules before posting.
    Forum Rules
    Need and assistance with your issue? use this section to ask for assistance !
    My Portfolio
    Wanna learn PHP ? check out my One-Page project

  2. The Following 3 Users Say Thank You to Vitrex For This Useful Post:

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts