Jump to content
Welcome, Guest
Existing user? Sign In

Sign In



Sign Up
The MatriX
  • Welcome To Ghbsys
  • CS GO Streaming Version is released. Have fun streaming while cheating!
  • Have a Payment Issue? Send us a Support ticket.
  • Make a thread if you need support or join our discord for live support.
  • Have Suggestions? Make a thread and you'll earn Ghbsys Points for implemented suggestions.
  • Join our discord to stay well connected! Don't forget to integrate your discord to the site
  • Welcome to [GHB] - GAmEhAcKbAsTaRdS Forum

    Welcome to [GHB] - GAmEhAcKbAsTaRdS Forum, like most online communities you must register to view or post in our community, but don't worry this is a simple free process that requires minimal information for you to signup. Be apart of [GHB] - GAmEhAcKbAsTaRdS Forum by signing in or creating an account.
    • Start new topics and reply to others
    • Subscribe to topics and forums to get email updates
    • Get your own profile page and make new friends
    • Send personal messages to other members.

    PHP variables and functions


    House
     Share

    Recommended Posts

    Hello, I show you a bit of the basics of variables in PHP xD

     

    Every piece of script should be between

    <?php

    and at the end of your whole script

    ?>

     

    Okay, now to the variables:

     

    If you want to declare a variable, just simply think of a name, and put $ in front of it.

    For example, if you want a variable for username or so:

    $username = "hallo";

     

    Always put strings (letters) between " and " (quotation marks), integers (numbers, 0-9) don't need quotation marks, neither do booleans (TRUE or FALSE, 0 or 1 works too)

     

    if you want to look, what a variable is like and do something with it,

    for example: if you want to start a piece of script when the variable is 1 or TRUE, do:

    if($username == 1)
    {
     echo "The username is 1.";
    }

     

    remember, if you want to DECLARE a variable, write: "="

    if you want to CHECK a variable, write: "=="

    otherwise in if($username = 1) the piece will be execute after he changed it to 1, and he does it^^

     

    if you want to take variables from something someone entered in a form, it depends on the method you use.

    If the method is POST, use $_POST[' name of the input field '], if the method is GET, use $_GET[' name of the input field '].

     

    Remember, close EVERY sentence with a ";", a semicolon.

     

    Example for a mailing script:

     

    <html>
    <head>
    </head>
    <body>
    
    <form action=" <?php PHP_SERVER['self']; ?> " method="GET">
    Your name:<br>
    <input type="text" name="name" /><br>
    eMail of the person you want to mail:<br>
    <input type="text" name="address" /><br>
    Subject:<br>
    <input type="text" name="subject" /><br>
    Content of the mail:<br>
    <input type="text" name="content" /><br>
    <input type="submit" name="submit" value="submit email!" /><br>
    </form>
    
    <?php
    //If the SUBMIT button is pressed, THEN
    if(isset($_POST['submit']))
    {
    $name = $_POST['name'];
    $mail = $_POST['address'];
    $content = $_POST['content'];
    $subject = $_POST['subject'];
    
    //Now we start the mail, REMEMBER, mailscripts will only work on servers where the mailing
    //Function is enabled!
    mail($mail, $subject, $content, "From: ".$name) or die("Mail could not be sent.");
    
    //The or die function means, IF it doesn't work, then do this: (what's between the clamps ())
    }
    ?>
    </body>
    </html>

     

    Have fun^^

    credits: nobody, everything selfcoded

    Link to comment
    Share on other sites

    Woh thats better^^

    thanks i will try it read it completely tomorrow i suppose.

    thanks xD

    Link to comment
    Share on other sites

    yeh it works i wanna have some more i can do only some with nvu (its a html editor O.o)

     

    Download Adobe DreamWeaver™ I can send you some download links this afternoon xD

    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    Loading...
     Share

    • Recently Browsing   0 members

      • No registered users viewing this page.
    ×
    ×
    • Create New...