Skip to content

Instantly share code, notes, and snippets.

@dipunj
Last active April 12, 2017 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dipunj/dba8c53b3db0b46d28303609204ecda5 to your computer and use it in GitHub Desktop.
Save dipunj/dba8c53b3db0b46d28303609204ecda5 to your computer and use it in GitHub Desktop.
Contains Web Development Notes


CLASS #2

JANUARY, 2017


  1. Server client are processes, and shouldn't be associated with physical machines.

  2. ports are 16bit integers.

  3. Target port must be predetermined.

i.e target port is known beforehand

  1. Browser only understands HTML, and server always returns a static page to the browser.

  2. Server-Client == Request-Response system

  3. HTML comment stays in the final output page response(php).


pHp

  1. php = hypertext preprocessor

  2. php engine ignores everything else apart from php code.

  3. php doesn't distinguish between " " and ' '

  4. php is a loose type-setting language

  5. variable declarations are prefixed by $

  6. arrays in php

  1. Indexed arrays
  2. Associative arrays

Index may not be an integer, use string as an index.

  1. Declaring Arrays a.Indexed Arrays:

     $array_name = array("value",...)
    

b.Associative Arrays:

	$array_name = array("key"=>"value",...)
  1. var_dump -> prints type of the variable.

  2. types is a data type in php but are internally handled.

  3. loops a)for() b)while() c)foreach($arr as $key => $var)
    Note : $key is optional, $arr and $key remain untouched, effectively the values used in foreach loop are just copies of $arr,$key```

  4. . concatenates two strings "abc"."xyz" = "abcxyz"

  5. types of equality or inequality a. != : not equal b. == : equal c. ===: equal and of same type

  6. Types of variables

  • local
  • global : syntax :: global $varname if $varname is a global variable
  • superglobal : accessible anywhere
  1. How to make functions

    function function_name(function parameters)
    {
    		// function body
    }
    

function parameters can be initialized so $x = 3 in the parameter list means that x is initialised to 3. else if function was called with another value of x then x is overwritten with that value DEFAULT VALUES MUST BE TO THE EXTREME RIGHT

  1. Super Globals : $_POST $_GET

All input variables are stored in these super globals as associative arrays

eg. $name was filled in by the user, i.e $name = xyz

$_POST['name'] = 'xyz'


CLASS #3:

FEBRUARY 6TH, 2017


  1. We need a php engine to run the php scripts.

  2. htdocs is considered the root directory by the server (XAMPP).

  3. Initially the server tries to find two files :- a. index.html b. index.php else it opens the full directory listing.

  4. $_POST and $_GET are associative arrays.

  5. HTML is case sensitive but php is not.

  6. Browser is dumb : it doesn't know whether the php output contains an HTML tag etc.

  7. htmlentities() : it can stop C-SS attacks always use htmlentities() to sanitize user input. htmlspecialchars() == htmlentities().

  8.  isset() :
     if(!isset($_POST['submit']))
     {
     	die('can't open page like this');
     }
  9. trim() : removes the extreme spaces in the user input.

  10. die() : kills the page instantaneously and shows the error message.

  11. URL ENCODING : %20 : space

  12. GET :-> data is copied in the URL as it is.

  13. POST :-> you can see the form data in developer tools in the browser. BOTH POST and get are insecure.

  14. Front-end checks are done for a innocent user, not for a hacker.

  15. $_SERVER a. HTTP_USER_AGENT b. $HTTP_ACCEPT c. $REMOTE_ADDR d. $REMOTE_PORT

  16. == ''
  17. header("aandolan.html") : TO redirect form to aandolan.html

  18. $_REQUEST : union of the GET and POST.


COOKIES

  1. Once you successfully login inti the server then you are alloted a session id, which can be reused whenever you login again.
  2. session_start() :: server creates a cookie for the session. TO BE DONE whenever handling sessions.
  3. session variables are accessible accross webpages.
  4. session_destroy()

HOW TO INCLUDE FILES IN pHp?

  1. include('path name of the file');
  2. include_once('path name of the file') :-> includes file only once, removes the redundancies.
  3. require('path name of the file')
  4. require_once('path name of the file') relative path : portable absolute path : not portable.

CROSS-SITE SCRIPTING ATTACK

MySQL

structered query language. It is a relational DBMS

  1. Data is stored in tables.
  2. COMMAND TYPES :- A. DDL B. DML C. TCL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment