project sukhi

Upload: sukhdeep-singh

Post on 07-Apr-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/4/2019 Project Sukhi

    1/35

    Sant Longowal Instituteof Engineering & Technology

    (Deemed To Be University)

    Training Report On

    PHP

    Submitted in Partial Fulfillment of The Requirement ForTwo Month Industrial Training

    at

    HCL CDC, Chandigarh

    (from JUNE 2011 to JULY 2011 )

    Submitted to: Submitted by:

    CSE Department, SLIET Sukhdeep SinghGCS/105902

  • 8/4/2019 Project Sukhi

    2/35

    2

    Index 1. Acknowledgement (Page 3)

    2. Preface (Page 4)3. About HCL (Page 5)4. HTML (Page 6-12)

    a. HTML tagsb. HTML Headingc. Linksd. Paragraphse. Imagesf. Elementsg. Attributesh. Stylei. Tables j. Forms

    5. PHP (Page 13-21)a. Syntaxb. Variablesc. Concatenation operatord. Conditional Statementse. Loopsf. Functionsg. Sessionh. Cookiesi. Database Connectivity

    j. Inserting and Retrieving datak. Updating and Deleting data

    6. Project (Page 22-34)a. Software development phasesb. Technologies Usedc. Hardware and Software Requirementsd. Database Structuree. Screenshots

    7. Bibliography (Page 35)

  • 8/4/2019 Project Sukhi

    3/35

    3

    Acknowledgement

    I owe a great many thanks to a great many people who helped andsupported me during the training period.

    We wish to express our heartiest gratitude to Mr. Akash Kumar fortheir proper guidance, constant encouragement, constructivesuggestions, thought provoking decisions and giving us fullopportunity to practically handle the system without whosesupervision this could not be possible.

    I would like to thank the whole of the training department of Sant Longowal Institute of Engineering & Technology especially to Dr.Pardeep Gupta (HOD, T&P) . In addition of these I was also helped byMr. Birmohan Singh (HOD, CSE) for providing me all necessary help.

    Sukhdeep SinghGCS/105902

  • 8/4/2019 Project Sukhi

    4/35

    4

    Preface

    The aim of the training is to work in technical area and gainpractical knowledge. It is to expose the student to the databaseenvironments. It is to apply theoretical knowledge to practicalsituation and to appreciate the limitations of knowledge gained inthe classroom. It is to appreciate the importance of discipline,punctuality, team work and sense of responsibility, value of time,money and dignity of labor. It is to understand the psychology of theworkers and their habits, attitudes and approach to problem solvingalong with practice followed in the industry. It is to get exposed tothe current technological development relevant to the subject areato which the project pertain. It is the best way to present effort andforming and updating technical skill of the student.

    The project entitled ( iMart Website ) programming submitted by mein the partial fulfillment of the requirement for the award Degree inComputer Science and Engineering from SLIET carried out

    successfully under the guidance of Mr. Birmohan Singh (HOD, CSE) & ER. MAJOR SINGH.

  • 8/4/2019 Project Sukhi

    5/35

    5

    About HCL Enterprise

    HCL draws its strength from 30 years of experience in handling theever changing IT scenario , strong customer relationships , ability toprovide the cutting edge technology at best-value-for-money and ontop of it , an excellent service & support-infrastructure.Today HCL is country's premier information enabling company. Itoffers one-stop-shop convenience to its diverse customers having anequally diverse set of requirements. Be it a large multi-locationenterprise, or a small/medium enterprise, or a small office or a

    home, HCL has a product range, sales & support capability to servicethe needs of the customer. Last 30 years apart from knowledge &experience have also given us continuity in relationship with thecustomers, thereby increasing the customer confidence in thecompany.

    It has operations spanning 31 countries with delivery facilitiesin USA, UK, Finland, Poland, Puerto Rico, Brazil, China, Malaysia,Singapore, Australia, Czech Republic, and India to support in-shoreand out-shore customers. Strengths can be summarized as:

    Ability to understand customer's business and offer righttechnology

    Long standing relationship with customers Pan India support & service infrastructure Best-vale-for-money offerings

  • 8/4/2019 Project Sukhi

    6/35

    6

    What is HTML?HTML is a language for designing web pages.

    HTML stands for Hyper Text Markup Language

    HTML is not a programming language, it is a markup language A markup language is a set of markup tags

    HTML TagsHTML markup tags are usually called HTML tags

    HTML tags are keywords surrounded by angle brackets like

    HTML tags normally come in pairs like and The first tag in a pair is the start tag, the second tag is the end

    tag Start and end tags are also called opening tags and closing tags.

    HTML Headings

    HTML headings are defined with the to tags.ExampleThis is a headingThis is a headingThis is a heading

    HTML ParagraphsHTML paragraphs are defined with the

    tag.Example

    This is a paragraph

    This is another paragraph

  • 8/4/2019 Project Sukhi

    7/35

    7

    HTML LinksHTML links are defined with the tag.Example

    This is a link

    HTML ImagesHTML images are defined with the tag.Example

    HTML ParagraphsParagraphs are defined with the

    tag.Example

    This is a paragraph

    This is another paragraph

    HTML ElementsAn HTML element is everything from the start tag to the end tag:Start tag Element content End tag

    This is a paragraph

    This is a link

    HTML Element Syntax An HTML element starts with a start tag An HTML element ends with an end tag The element content is everything between the start and end

    tag Some HTML elements have empty content Some HTML elements have a missing end tag

  • 8/4/2019 Project Sukhi

    8/35

    8

    HTML Attributes HTML elements can have attributes Attributes provide additional information about the element

    Attributes are always specified in the start tag

    HTML Style Examplesstyle="background-color:yellow"style="font-size:10px"style="font-family:Times"style="text-align:center"

    The Image Tag and the Src AttributeIn HTML, images are defined with the tag. The tag isempty, which means that it contains attributes only and it has noclosing tag.

    To display an image on a page, you need to use the src attribute. Srcstands for "source". The value of the src attribute is the URL of theimage you want to display on your page.The syntax of defining an image:

    The Alt Attribute The alt attribute is used to define an "alternate text" for an image if image is not loaded.

    The "alt" attribute tells the reader what he or she is missing on apage if the browser can't load images.

  • 8/4/2019 Project Sukhi

    9/35

    9

    Tables

    Tables are defined with the tag. A table is divided into rows

    (with the tag), and each row is divided into data cells (with the tag). The letters td stands for "table data," which is the contentof a data cell. A data cell can contain text, images, lists, paragraphs,forms, horizontal rules, tables, etc.row 1, cell 1row 1, cell 2row 2, cell 1row 2, cell 2Browser Preview:

    row 1, cell 1 row 1, cell 2row 2, cell 1 row 2, cell 2

    Headings in a TableHeadings in a table are defined with the tag.

    HeadingAnother Headingrow 1, cell 1row 1, cell 2

  • 8/4/2019 Project Sukhi

    10/35

    10

    row 2, cell 1row 2, cell 2

    Browser Preview:Heading Another Heading

    row 1, cell 1 row 1, cell 2

    row 2, cell 1 row 2, cell 2

    FormsA form is an area that can contain form elements.Form elements are elements that allow the user to enter information(like text fields, textarea fields, drop-down menus, radio buttons,checkboxes, etc.) in a form.

    A form is defined with the tag.

    Input The most used form tag is the tag. The type of input is

    specified with the type attribute. The most commonly used inputtypes are explained below.Text FieldsText fields are used when you want the user to type letters,

    numbers, etc. in a form.

  • 8/4/2019 Project Sukhi

    11/35

    11

    First name:


    Last name:

    How it looks in a browser:First name:Last name:

    Radio ButtonsRadio Buttons are used when you want the user to select one of alimited number of choices. Male

    FemaleHow it looks in a browser:

    MaleFemale

    Note that only one option can be chosen.

    CheckboxesCheckboxes are used when you want the user to select one or moreoptions of a limited number of choices.I have a bike:
    I have a car:

  • 8/4/2019 Project Sukhi

    12/35

    12


    I have an airplane:

    How it looks in a browser:Computer:Laptop:Palmtop:

    The Form's Action Attribute and the Submit Button

    When the user clicks on the "Submit" button, the content of the form is sent to the server. The form's action attribute defines thename of the file to send the content to. The file defined in the actionattribute usually does something with the received input.Username:How it looks in a browser:

    Username:Submit

    If you type some characters in the text field above, and click the"Submit" button, the browser will send your input to a page called"html_form_submit.php". The page will show you the received input.

  • 8/4/2019 Project Sukhi

    13/35

    13

    What is PHP?

    PHP is a powerful server side scripting language originally

    designed for web development to produce dynamic web pages. Forthis purpose, PHP code is embedded into the HTML sourcedocument and interpreted by a web server with a PHP processormodule, which generates the web page document. It also hasevolved to include a command-line interface capability and can beused in standalone graphical applications. PHP can be deployed onmost web servers and as a standalone interpreter, on almost everyoperating system and platform free of charge. PHP is installed on

    more than 20 million websites and 1 million web servers.PHP was originally created by Rasmus Lerdorf in 1995. PHP primarilyacts as a filter, taking input from a file or stream containing textand/or PHP instructions and outputs another stream of data; mostcommonly the output will be HTML.Latest version of PHP is 5.3.6. A new major version has been underdevelopment alongside PHP 5 for several years. This version wasoriginally planned to be released as PHP 6 as a result of its significantchanges, but later they dropped the plan and move on to developPHP 5.4.0.

    Structure Object-oriented, ProceduralAppeared in 1995

    Latest Stable Release 5.3.6Influenced by C, Perl, Java, C++OS Cross-PlatformLicense PHP LicenseFile Extension .php .phtml

  • 8/4/2019 Project Sukhi

    14/35

    14

    Basic Syntax of PHP

    A PHP scripting block always starts with . A

    PHP scripting block can be placed anywhere in the document.

    A PHP file normally contains HTML tags, just like an HTML file, andsome PHP scripting code.Below, we have an example of a simple PHP script which sends thetext "Hello World" to the browser:

    PHP VariablesIn PHP, a variable does not need to be declared before adding a

    value to it.$var_name = value;

    We do not have to tell PHP which data type the variable is. Stringvariables are used for values that contain characters.

    $txt="Hello World";

  • 8/4/2019 Project Sukhi

    15/35

    15

    The Concatenation OperatorThere is only one string operator in PHP.The concatenation operator (.) is used to put two string valuestogether.To concatenate two variables together, use the dot (.) operator:

    Output:Hello World 1234

    Conditional Statments

    Switch StatementUse the switch statement to select one of many blocks of code to be executed.switch ( n){Case 1: Code;break;Case 2: Code;break;default: Code;}

    If. ElseUse the if statement to execute some code only if a specifiedcondition is true.if (condition )

    code to be executed if condition is true;

  • 8/4/2019 Project Sukhi

    16/35

    16

    elsecode to be executed if condition is false;

    Loops

    In PHP, we have the following looping statements: while - loops through a block of code while a specified

    condition is truewhile ( condition ){

    code to be executed ;}

    do...while - loops through a block of code once, and thenrepeats the loop as long as a specified condition is true

    do{

    code to be executed;

    }while ( condition ); for - loops through a block of code a specified number of

    timesfor (init; condition; increment/decrement ){

    code to be executed;}

    foreach - loops through a block of code for each elementin an array

    foreach ($ array as $value ){code to be executed;}

  • 8/4/2019 Project Sukhi

    17/35

    17

    PHP Functions

    Create a PHP Function

    A function is a block of code that can be executed whenever we needit.

    Creating PHP functions: All functions start with the word "function()" Name the function - It should be possible to understand what

    the function does by its name. The name can start with a letter

    or underscore (not a number) Add a "{" - The function code starts after the opening curly

    brace Insert the function code Add a "}" - The function is finished by a closing curly brace

    ExampleA simple function that writes my name when it is called:

  • 8/4/2019 Project Sukhi

    18/35

    18

    Use a PHP Function

    Now we will use the function in a PHP script:

  • 8/4/2019 Project Sukhi

    19/35

    19

    Before you can store user information in your PHP session, youmust first start up the session.

    session_start();The correct way to store and retrieve session variables is to usethe PHP $_SESSION variable:

    $_SESSION*varname+=Hello; You can completely destroy the session by calling thesession_destroy() function.

    Session is valid only until the user has kept the webpage opened inthe browsers, one the user closes the tab or goes to another site, the

    session expires and all values are unset.

    PHP Cookies

    A cookie is often used to identify a user. A cookie is a small filethat the server embeds on the user's computer. Each time the samecomputer requests a page with a browser, it will send the cookie too.With PHP, you can both create and retrieve cookie values.

    The setcookie() function is used to set a cookie.setcookie(name, value, expire, path, domain);

    The PHP $_COOKIE variable is used to retrieve or Insert a cookievalue:

    $_COOKIE*varname+=HELLO;

    When deleting a cookie you should assure that the expiration dateis in the past.

  • 8/4/2019 Project Sukhi

    20/35

    20

    PHP with MySQLBefore you can access data in a database, you must create aconnection to the database.

    mysql_connect(servername,username,password);

    Usually Server is localhost when you are using it from a localmachine. And default username and password are root and NULL.

    The CREATE DATABASE statement is used to create a database inMySQL.

    CREATE DATABASE database_name

    The CREATE TABLE statement is used to create a table in MySQL.

    CREATE TABLE table_name( column_name1 data_type, .... )

    Inserting into Database

    The mysql_select_db() statement is used to select from a databaseserver.

    mysql_select_db(database_name, $connection_var);

    The INSERT INTO statement is used to add new records to a databasetable.

    INSERT INTO table_nameVALUES (value1, value2, value3,...)

    Example:

  • 8/4/2019 Project Sukhi

    21/35

    21

    mysql_query("INSERT INTO Persons (FirstName, LastName, Age)VALUES ('Peter', 'Griffin', '35')");

    SELECT Statement

    The SELECT statement is used to select data from a database.SELECT column_name(s)FROM table_name

    The WHERE clause is used to filter records.SELECT column_name(s)FROM table_nameWHERE column_name operator value

    The ORDER BY keyword is used to sort the data in a recordset.SELECT column_name(s)FROM table_nameORDER BY column_name(s) ASC|DESC

    MySQL Update and Delete

    The UPDATE statement is used to update existing records in a table.UPDATE table_nameSET column1=value, column2=value2,...

    WHERE some_column=some_value

    The DELETE FROM statement is used to delete records from adatabase table.

    DELETE FROM table_nameWHERE some_column = some_value

  • 8/4/2019 Project Sukhi

    22/35

    22

    Project Details

    Our Project has been focussed on E-Commerce and thus user can

    simply go through the website, finds its desired product and shop forit. I have focussed more on the simplicity then the design, so thatuser should not feel the complexity while browsing through thewebsite. Main features of the Website are:

    User can also simply use the search box to find a specificproduct..

    All Products sorted accordingly to their category and sub-category, so it is easier to browse through the specific category.

    Registered user can comment on any specific product and giveits feedback.

    Detailed product specification for products such as laptops andmobiles.

    Feedback and Contact forms are also added to get feedbackfrom user regarding the website.

    Admin can Add a new product to the website database.

    Software Development Phases:

    Requirement AnalysisThe analysis phase defines the requirements of the system,

    independent of how these requirements will be accomplished. Thisphase defines the problem that the customer is trying to solve. The requirement gathering process is intensified and focusedspecifically on software. To understand nature of the program to bebuilt, the software engineer (analyst) must understand theinformation domain for the software as well as required function,behavior, performance, and interface.

  • 8/4/2019 Project Sukhi

    23/35

    23

    DesignThe system and software design is actually a multistep process

    that focuses on some attributes of a program, such as: Datastructure, Software architecture, Interface representations andProcedural details. The design process translates requirements intorepresentation of software that can be accessed for quality beforecoding begins. In the design phase, the decomposition of theproblem leads to the development of data structures and algorithms.

    Code GenerationThe design must be translated into a machine readable form.

    The code generation step performs this risk. The design part istranslated into coding part by using some programming languages.

    TestingOnce code has been generated program testing begins. Testing

    is done for checking the correctness of the design or software.Incorrect decisions can be recognized and correct earlier. During testphase, not only new products but also of the reused components istested and define output will produce correct result that agree withrequired output.

    MaintenanceMaintenance phase can reapply each of the proceeding phases

    to an existing program rather than a new one.

    Technologies used:

    Front End: HTML, CSS, Java-script, PHPBack End: MySQLServer: ApachePHP Version: 5.3.4

  • 8/4/2019 Project Sukhi

    24/35

    24

    Hardware Requirement:Following is the minimum System requirement to host this

    website:Processor: Intel Pentuim IV or Equivalent running @ 1.6 Ghz ormore. (x86/x64)RAM: 256 MB

    Software Requirement : Web-Server such as Apache or IIS. PHP 5.2.0 or higher. MySQL Server

    DatabaseMySQL has been used as database for the website. Here is thedatabase structure for the website:

    Database Name: iMartNo. of tables in Database: 7 admin User Product lspec mspec comments order

    Table Structure:

    adminField TypeUsername Varchar(13)

    Password Varchar(15)

  • 8/4/2019 Project Sukhi

    25/35

    25

    UserField TypeUser_id Varchar(17)

    Email Varchar(25)Name Varchar(30)Contact Int(12)Password Varchar(15)Address TextCity Varchar(20)Zipcode Int(6)State Varchar(15)

    Product:Field TypeProduct_id Varchar(13)

    Name Varchar(50)Price Int(8)Iprice Int(8)Image Varchar(100)Category Int(1)Date DateSold Int(5)Save Int(2)

    Sub Int(1)Description Text

    lspecField TypeProduct_id Varchar(13)

    Processor Varchar(30)Ram Varchar(30)

  • 8/4/2019 Project Sukhi

    26/35

    26

    Screen Varchar(30) Hdd Varchar(30) Igraphics Varchar(50)

    Dgraphics Varchar(50) Optical Varchar(50) Weight Varchar(50) OS Varchar(50) Webcam Varchar(50) Bluetooth Varchar(50) Esata Varchar(10) HDMI Varchar(10)

    Ethernet Varchar(10) Wifi Varchar(10) Battery Varchar(30) Usb Varchar(20) Other Text

    mspecField TypeProduct_id Varchar(13)Ntype Varchar(2)Dim Varchar(30) Weight Varchar(15) Type Varchar(20) Resolution Varchar(30) Memory Varchar(15)

    Ememory Varchar(30) Talktime Varchar(10) Standby Varchar(10) Cam Varchar(15) Os Varchar(15) Bluetooth Varchar(10) Wifi Varchar(4) Sms Varchar(3) Mms Varchar(3)

  • 8/4/2019 Project Sukhi

    27/35

    27

    Mail Varchar(4) Java Varchar(4) Other Text

    commentsField TypeProduct_id Varchar(13)User Varchar(25)Time TimestampComment Text

    orderField TypeOrder_id Varchar(20)User-id Varchar(20)uname Varchar(25)Product_id Varchar(25)

    Pname Varchar(25)Price Int(6)Address TextPin Int(6)City Varchar(20)State Varchar(20)

  • 8/4/2019 Project Sukhi

    28/35

    28

    Screenshots

    Index/Home Page

    Books Category Page

  • 8/4/2019 Project Sukhi

    29/35

    29

    Games Category Page

    Product Page

  • 8/4/2019 Project Sukhi

    30/35

    30

    Comments Section

    Search Page

  • 8/4/2019 Project Sukhi

    31/35

    31

    Sign-in Page

    Buy Product Page

  • 8/4/2019 Project Sukhi

    32/35

    32

    Admin Panel

    Data Entry Page

  • 8/4/2019 Project Sukhi

    33/35

    33

    Data Entry 2(Mobile)

    Data Entry 3 (Computer/Laptop)

  • 8/4/2019 Project Sukhi

    34/35

    34

    Feedback

  • 8/4/2019 Project Sukhi

    35/35

    35

    Bibliography

    HCL CDC

    PHP.Net official site Google search Engine Wrox PHP, Apache, MySQL web development Wiley PHP 5