News Portal Report

You might also like

You are on page 1of 38

NEWS PORTAL

A project report submitted in the partial


fulfilment of the requirement for the award of degree of
Bachelor of Technology CSE
(Session: 2009-2013)

Submitted To: Submitted By:


Er. Arun Malik Jyoti Verma
6310806
CSE-IVth Year

GURU NANAK INSTITUTE OF TECHNOLOGY

MULLANA

AFFILIATED TO

KURUKSHETRA UNIVERSITY,KURUKSHETRA,HARYANA

2009-2013
CHAPTER 1
INTRODUCTION

Introduction to Project
Online news portal allows customers to read up to date news related to many fields like
entertainment, national, international, business, sports etc. without any payment or login.
He can also contact us to give suggestions and can also give us feedback related to our site.
New News can be added only by the admin and only admin have the right to update or delete
any News. Admin have the right to give authority to other for news update, add or
Delete.
The traditional media rooms all around the world are fast adapting to the new age technologies.
This marks the beginning of news portals by media houses across the globe. This new media
channels give them the opportunity to reach the viewers in a shorter span of time than their print
media counterparts.

MODULES

User

A user can directly read any type of news related to any field like entertainment, sports, business,
national, international etc. without login and also contact us or can give suggestions and
feedback.

Admin

Admin is the one who have the authority to see all the users feedback into the website. He can
register new accounts and also delete or update accounts. It means he have the authority to
handle the whole website. He can update, add or delete any news relate to any field.
Advantages

 News on the Internet can be updated round the clock so that readers can have the most
up-to-date news any time of the day or night.

 Once a news item is put on the Internet, it becomes instantly available for use round the
globe without additional variable costs.
 The lead time required between occurrence of an event and news making on it available
on the Internet has reduced considerably. Some items of news like stock market prices
are now available almost in real-time.
 News provider can get detailed data on popularity of news items. This information can
help in better choice of information put on the site.

 The type of news and the way it is presented can be customized to the needs and
preference of individual readers

 You don't have to wait for newspaper in morning.

 Any time any news related to different fields will be available.


 Money and time will also save.

Disadvantages

 Newspapers are more convenient to read. One can easily relax, reclined over a deck
chair, and reading a newspaper. This Kind of ease in reading is not possible with Internet-
news.

 Newspaper can be carried and read at any location of the world. There is no precondition
of availability of Internet connectivity.

 Newspaper can be carried and read at any location of the world. There is no precondition
of availability of Internet connectivity.

 Reading newspaper does not require any equipment such as a computer.

 It is important to note that Internet capabilities are improving very fast, and with that the
Internet-news is moving toward overcoming its current disadvantages over newspaper.
CHAPTER 2
TECHNOLOGY USED
Technology Used:

PHP, MySql, HTML, Javascript.

2.1 Front End:

PHP, HTML, Javascript.

2.2 Back End:

MySql.

PHP

PHP is a programming language designed to generate web pages interactively on the computer
serving them, called a web server. Unlike HTML, where the web browser uses tags and markup
to generate a page, a PHP code runs between the requested page and the web server, adding to
and changing the basic HTML output.
While PHP is great for developing web functionality, it is not a database. The database of choice
for PHP developers is MySQL, which acts like a filing clerk for PHP-processed user
information. MySQL automates the most common tasks related to storing and retrieving specific
user information based on your supplied criteria.
MySQL is easily accessed from PHP, and they’re commonly used together as they work well
hand in hand. An added benefit is that PHP and MySQL run on various computer types and
operating systems.
Birth of PHP

PHP grew out of a need for people to develop and maintain web sites containing dynamic client-
server functionality. In 1994, RasmusLerdorf created a collection of open source Perl scripts for
his personal use, and these eventually were rewritten in C and turned into what PHP is today.
The real beauty of PHP is its simplicity coupled with its power, as well as it being an interpreted
language, rather than a compiled one.
Compiled languages create a binary .exe file, while interpreted languages work directly with the
source code when executing as opposed to creating a standalone file.

Why PHP?

 PHP runs on different platforms (Windows, Linux, Unix, etc.)


 PHP is compatible with almost all servers used today (Apache, IIS, etc.)
 PHP is FREE to download from the official PHP resource: www.php.net
 PHP is easy to learn and runs efficiently on the server side

What is PHP?

 PHP stands for PHP: Hypertext Preprocessor


 PHP is a server-side scripting language, like ASP
 PHP scripts are executed on the server
 PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL,
Generic ODBC, etc.)
 PHP is an open source software
 PHP is free to download and use
What is a PHP File?

 PHP files can contain text, HTML tags and scripts


 PHP files are returned to the browser as plain HTML
 PHP files have a file extension of ".php", ".php3", or ".phtml"
What is MySQL?

 MySQL is a database server


 MySQL is ideal for both small and large applications
 MySQL supports standard SQL
 MySQL compiles on a number of platforms
 MySQL is free to download and use.

Birth of MySQL

MySQL was developed in the 1990s to fill the ever-growing need for computers to manage
information intelligently. The original core MySQL developers were trying to solve their needs
for a database by using mSQL, a small and simple database. It became clear that mSQL couldn’t
solve all the problems they wanted it to, so they created a more robust database that turned into
MySQL.

MySQL supports several different database engines. The database engine determines how
MySQL handles the actual storage and querying of data. Because of that each storage has its own
set of abilities and strengths. Over time, the database engines available are becoming advanced
and faster. For general web-driven tasks, the default MyISAM database engine works perfectly
fine.

Advantages of Using PHP with MySQL

 PHP combined with MySQL are cross-platform (you can develop in Windows and serve
on a Unix platform).
 PHP and MySQL work well together.The programming interfaces between them are
logically paired up.
 PHP and MySQL have open source power. PHP and MySQL can both be used for free.
MySQL client libraries are no longer bundled with PHP.
 PHP and MySQL are fast. Their simplicity and efficient design enables faster processing.
 PHP and MySQL don’t bog you down with unnecessary details.

2.3About PHP5
Only time will tell if the PHP 5 release will be as successful as its two predecessors
(PHP 3 and PHP 4). The new features and changes aim to rid PHP of any weaknesses it may
have had and make sure that it stays in the lead as the world’s best web-scripting language.
However , if you are familiar with PHP 4 and are eager to know what is new in PHP 5.

2.4 Language Features

 New Object-Oriented Model


Added the object-oriented syntax back in the days of PHP 3, it was added as “syntactic sugar
for accessing collections.” The OO model also had support for inheritance and allowed a
class (and object) to aggregate both methods and properties, but not much more. When Zeev
and Andi Gutmans rewrote the scripting engine for PHP 4, it was a completely new engine; it
ran much faster, was more stable, and boasted more features. However, the OO model first
introduced in PHP 3 was barely touched. Although the object model had serious limitations,
it was used extensively around the world, often in large PHP applications. This impressive
use of the OOP paradigm with PHP 4, despite its weaknesses, led to it being the main focus
for the PHP 5 release.

For example:
class Person {
var $name;
function getName()
{
return $this->name;
}
function setName($name)
{
$this->name = $name;
}
function Person($name)
{
$this->setName($name);
}
}
function changeName($person, $name)
{
$person->setName($name);
}
$person = new Person("Andi");
changeName($person, "Stig");
print $person->getName();

 public/ private/ protected access modifiers for methods and properties. Allows the
use of common OO access modifiers to control access to methods and properties:

class MyClass {
private $id = 18;
public function getId() {
return $this->id;
}
}

 Interfaces: Gives the ability for a class to fulfill more than one is-a relationships. A class
can inherit only from one class, but may implement as many interfaces as it wants:

interface Display {
function display();
}
class Circle implements Display {
function display() {
print "Displaying circle\n";
}
}
 Instance of operator: Language-level support for is-a relationship checking. The PHP 4
is_a() function is now deprecated:

if ($obj instanceof Circle) {


print '$obj is a Circle';
}

 Static methods.
You can now define methods as static by allowing them to be called from non-object context.
Static methods do not define the $this variable
because they are not bound to any specific object:
class MyClass {
static function helloWorld() {
print "Hello, world";
}
}
MyClass::helloWorld();

 Static members.
Class definitions can now include static members (properties) that are accessible via the class.
Common usage of static members is in the Singleton pattern:
class Singleton {
static private $instance = NULL;
private function __construct() {
}
static public function getInstance() {
if (self::$instance == NULL) {
self::$instance = new Singleton();
}
return self::$instance;
}
}

 Exception handling.
PHP 5 adds the ability for the well-known try/throw/catch structured exception-handling
paradigm. You are only allowed to throw objects that inherit from the Exception
class:
class SQLException extends Exception {
public $problem;
function __construct($problem) {
$this->problem = $problem;
}
}
try {
...
throw new SQLException("Couldn't connect to database");
...
} catch (SQLException $e) {
print "Caught an SQLException with problem $obj->problem";
} catch (Exception $e) {
print "Caught unrecognized exception";
}

 foreach with references.


In PHP 4, you could not iterate through an array and modify its values. PHP 5 supports this by
enabling you to mark the foreach() loop with the & (reference) sign, which makes any values
you change affect the array over which you are iterating:
foreach ($array as &$value) {
if ($value === "NULL") {
$value = NULL;
}
}

2.5HTML Embedding
PHP can be written in HTML tags. We start php with a delimiter <?php and is closed with a
delimiter ?>. For example
<HTML>
<HEAD>Sample PHP Script</HEAD>
<BODY>
The following prints "Hello, World":
<?php
print "Hello, World";
?>
</BODY>
</HTML>

2.6 Comments
We can write comments three different ways:
 C way
/* This is a C like comment
* which can span multiple
* lines until the closing tags
*/
 C++ way
// This is a C++ like comment which ends at the end of the line
 Shell way
# This is a shell like comment which ends at the end of the line

2.7 Variables
Variables in PHP are preceded with a $ sign, and similar to most modern languages, they can
start with a letter (A-Za-z) or_(underscore) and can then contain as many alphanumeric
characters and underscores as you like. Examples of variable names include $count, $_Obj,
$A123. The following code example uses variables:
$PI = 3.14;
$radius = 5;
$circumference = $PI * 2 * $radius; // Circumference =pie* d

2.8 Managing Variables


Three language constructs are used to manage variables.
2.8.1 isset()
isset() determines whether a certain variable has already been declared by PHP. It returns a
boolean value true if the variable has already been set, and false otherwise, or if the variable is
set to the value NULL
.
Consider the following script:
if (isset($first_name)) {
print '$first_name is set';
}
This code snippet checks whether the variable $first_name is defined. If $first_name is defined,
isset() returns true, which will display ' $first_name is set. ' If it isn’t, no output is generated.

2.8.2 unset()
unset() “undeclares” a previously set variable, and frees any memory that was used by it if no
other variable references its value. A call to isset() on a variable that has been unset() returns
false.
For example:
$name = "John Doe";
unset($name);
if (isset($name)) {
print ’$name is set';
}
This example will not generate any output, because isset() returns false.

2.8.3 empty()
empty() may be used to check if a variable has not been declared or its value is false. This
language construct is usually used to check if a form variable has not been sent or does not
contain data. When checking a variable’s truth value, its value is first converted to a Boolean
according to the rules in the following section, and then it is checked for true/false.
For example:
if (empty($name)) {
print 'Error: Forgot to specify a value for $name';
}
This code prints an error message if $name doesn’t contain a value that
evaluates to true.
2.9 Datatypes
Eight different data types exist in PHP, five of which are scalar and each of the remaining three
has its own uniqueness.

2.9.1 Integers
Integers are whole numbers and are equivalent in range as your C compiler’s long value. On
many common machines, such as Intel Pentiums, that means a 32-bit signed integer with a range
between –2,147,483,648 to +2,147,483,647. Integers can be written in decimal, hexadecimal
(prefixed with 0x), and octal notation (prefixed with 0), and can include +/- signs.

2.9.2 Floating Point Numbers


Floating-point numbers (also known as real numbers) represent real numbers and are equivalent
to your platform C compiler’s double data type. On common platforms, the data type size is 8
bytes and it has a range of approximately 2.2E–308 to 1.8E+308. Floating-point numbers include
a decimal point and can include a +/- sign and an exponent value. Examples of floating-point
numbers include 3.14, +0.9e-2, etc.
2.9.3 Strings
Strings in PHP are a sequence of characters that are always internally nullterminated. When
writing string values in your source code, you can use double
quotes ("), single quotes (') or here-docs to delimit them.
 Double Quotes Examples for double quotes:
"PHP: Hypertext Pre-processor"
"GET / HTTP/1.0\n"
"1234567890"
 Single Quotes In addition to double quotes, single quotes may also delimit strings.
However, in contrast to double quotes, single quotes do not support all the double quotes’
escaping and variable substitution
Examples:
'Hello, World'
'Today\'s the day'

2.9.4 Booleans
A Boolean value can be either true or false. Boolean is probably the type that other types are
most often converted to behind the scenes. This is because, in any conditional code such as if
statements, loops, and so on, types are converted to this scalar type to check if the condition is
satisfied. Also, comparison operators result in a Boolean value. Consider the following code
fragment:
$numerator = 1;
$denominator = 5;
if ($denominator == 0) {
print "The denominator needs to be a non-zero number\n";
}
The result of the equal-than operator is a Boolean; in this case, it would be false and, therefore,
the if() statement would not be entered.
2.9.5 Arrays
An array in PHP is a collection of key/value pairs. This means that it maps keys (or indexes) to
values. Array indexes can be either integers or strings whereas values can be of any type
(including other arrays).

2.9.5.1 array() construct Arrays can be declared using the array() language construct, which
generally takes the following form (elements inside square brackets, [], are optional):
array([key =>] value, [key =>] value, ...)
The key is optional, and when it’s not specified, the key is automatically assigned one more than
the largest previous integer key (starting with 0). Here’s an example of a nested array()
statement:
array(array("name" => "John", "age" => 28), array("name" => "Barbara", "age" => 67))

2.9.5.2 Accessing Array Elements Array elements can be accessed by using the $arr[key]
notation, where key is either an integer or string expression.

2.9.5.3 Reading array values You can use the $arr[key] notation to read array values. The next
example build on top of the previous example:
print $arr2["name"];
if ($arr2["age"] < 35) {
print " is quite young\n";
}
This example prints
John is quite young

2.10 Operators
PHP contains three types of operators: unary operators, binary operators, and one ternary
operator.
2.10.1 Binary Operators
2.10.2 Numeric Operators All the binary operators (except for the concatenation operator) work
only on numeric operands. If one or both of the operands are strings, Booleans, nulls, or
resources, they are automatically converted to their numeric equivalents before the calculation is
performed
(according to the previous table).

2.10.3 Concatenation Operator (.) The concatenation operator concatenates two strings. This
operator works only on strings; thus, any non-string operand is first converted to one. The
following example would print out "The year is 2000":
$year = 2000;
print "The year is " . $year;
The integer $year is internally converted to the string "2000" before it is concatenated with the
string’s prefix, "The year is".

2.10.4 Assignment Operators


Assignment operators enable you to write a value to a variable. The first operand (the one on
the left of the assignment operator or l value) must be a variable. The value of an assignment is
the final value assigned to the variable;for example, the expression $var = 5 has the value 5 (and
assigns 5 to $var).
Operator Name Value
+ Addition The sum of the two operands.
- Subtraction The difference between the two operands.
* Multiplication The product of the two operands.
/ Division The quotient of the two operands.
% Modulus Both operands are converted to integers. The result
is the remainder of the division of the first operand
by the second operand
In addition to the regular assignment operator =, several other assignment operators are
composites of an operator followed by an equal sign. These composite operators apply the
operator taking the variable on the left as the first operand and the value on the right (the r value)
as the second operand, and assign the result of the operation to the variable on the left. For
example:
$counter += 2; // This is identical to $counter = $counter + 2;
$offset *= $counter;// This is identical to $offset = $offset * $counter;
The following list show the valid composite assignment operators:
+=, -=, *=, /=, %=, ^=, .=, &=, |=, <<=, >>=

2.10.5 Comparison Operators


Comparison operators enable you to determine the relationship between two operands.
When both operands are strings, the comparison is performed lexicographically.The comparison
results in a Boolean value.
Operator Name Value
== Equal to Checks for equality between two arguments
performing type conversion when necessary:
1 == "1" results in true
1 == 1 results in true
!= Not equal to Inverse of ==.
> Greater than Checks if first operand is greater than second
< Smaller than Checks if first operand is smaller than second
>= Greater than or Checks if first operand is greater or equal to second
equal to
<= Smaller than or Checks if first operand is smaller or equal to second
equal to

=== Identical to Same as == but the types of the operands have to


match.No automatic type conversions are
performed:
1 === "1" results in False.
1 === 1 results in true.
!== Not identical to The inverse of ===.
!== Not identical to The inverse of ===.

2.10.6 Logical Operators


Logical operators first convert their operands to boolean values and then perform the respective
comparison.
Operator Name Value
== Equal to Checks for equality between two arguments
performing type conversion when necessary:
1 == "1" results in true
1 == 1 results in true
!= Not equal to Inverse of ==.
> Greater than Checks if first operand is greater than
second
< Smaller than Checks if first operand is smaller than
second
>= Greater than or Checks if first operand is greater or equal to
equal to second
<= Smaller than or Checks if first operand is smaller or equal to
equal to second

2.11 Control Structures


PHP supports a variety of the most common control structures available in other programming
languages. They can be basically divided into two groups: conditional control structures and
loop control structures.

2.11.1 Conditional Control Structures


Conditional control structures are crucial in allowing your program to take different execution
paths based on decisions it makes at runtime.

2.11.2 if Statements
if statements are the most common conditional constructs, and they exist in most programming
languages. The expression in the if statement is referred to as the truth expression. If the truth
expression evaluates to true, the statement or statement list following it are executed; otherwise,
they’re not. You can add an else branch to an if statement to execute code only if all the truth
expressions in the if statement evaluated to false:
if ($var >= 50) {
print '$var is in range';
} else {
print '$var is invalid';
}

2.11.3 Switch Statements


switch (expr){
case expr:
statement list
case expr:
statement list
...
default:
statement list
}
switch (expr):
case expr:
statement list
case expr:
statement list
...
default:
statement list
endswitch

2.12 Loop Control Structures


Loop control structures are used for repeating certain tasks in your program, such as iterating
over a database query result set.
2.12.1 while loops
while loops are the simplest kind of loops. In the beginning of each iteration, the while’s truth
expression is evaluated. If it evaluates to true, the loop keeps on running and the statements
inside it are executed. If it evaluates to false, the loop ends and the statement(s) inside the loop is
skipped. For example, here’s one possible implementation of factorial, using a while loop
(assuming $n contains the number for which we want to calculate the factorial):
$result = 1;
while ($n > 0) {
$result *= $n--;
}
print "The result is $result";
while (expr)
statement
while (expr):
statement list
endwhile;

2.12.2 do...while Loops


do
statement
while (expr);
The do...while loop is similar to the previous while loop, except that the truth expression is
checked at the end of each iteration instead of at the beginning. This means that the loop always
runs at least once. do...while loops are often used as an elegant solution for easily breaking out of
a code block if a certain condition is met. Consider the following example:
do {
statement list
if ($error) {
break;
}
statement list
} while (false);
Because do...while loops always iterate at least one time, the statements inside the loop are
executed once, and only once. The truth expression is always false. However, inside the loop
body, you can use the break statement to stop the execution of the statements at any point, which
is convenient. Of course, do...while loops are also often used for regular iterating purposes.

2.12.3 for Loops


PHP provides C-style for loops. The for loop accepts three arguments:
for (start_expressions; truth_expressions; increment_expressions)
Most commonly, for loops are used with only one expression for each of the start, truth, and
increment expressions, which would make the previous syntax table look slightly more familiar.
The start expression is evaluated only once when the loop is reached.
Usually it is used to initialize the loop control variable. The truth expression is evaluated in the
beginning of every loop iteration. If true, the statements inside the loop will be executed; if false,
the loop ends. The increment expression is evaluated at the end of every iteration before the truth
expression is evaluated. Usually, it is used to increment the loop control variable, but it can be
used for any other purpose as well. Both break and continue behave the same way as they do
with while loops. continue causes evaluation of the increment expression before it re-evaluates
the truth expression.
for (expr, expr, …; expr, expr, …; expr, expr, …)
statement
for (expr, expr, …; expr, expr, …; expr, expr, …):
statement list
endfor;
CHAPTER 3.
SYSTEM DESIGN

3.3 System Requirements

Requirements regarding the installation of PHP Environment has been listed below

 WAMP Server

WAMP is a form of mini-server that can run on almost any Windows Operating System.
WAMP includes Apache 2, PHP 5 (SMTP ports are disabled), and MySQL (phpMyAdmin and
SQL item manager are installed to manage your databases) preinstalled.An icon on the taskbar
tray displays the status of WAMP, letting you know if; a) WAMP is running but no services are
opened (the icon will appear red), b) WAMP is running and one service is opened (the icon will
appear yellow) or c) WAMP is running with all services opened (the icon will appear white).
Apache and MySQL are considered to be services (they can be disabled by left-clicking on the
taskbar icon, guiding your cursor over the service you wish to disable and selecting "Stop
Service").
The files/web pages that are hosted on your WAMP server can be accessed by typing
http://localhost/ or http://127.0.0.1/ in the address bar of your web browser. WAMP must be
running in order to access either of the above addresses.
If you would like to share your files/web pages with others, click on the icon located on your
taskbar tray and select "Put Online." You must have access to the Internet in order to continue.
Send the people that you would like to give access to the files/web pages hosted on your WAMP
server IP Address. Your can find your IP address here:

 MYSQL as Database
 PHP as platform.
DATABASE DESIGN

3.3 Database Tables

Field Type NULL Key


Id Varchar(11) N0 ----------
Title Varchar(200) yes -----------
Description Text yes -----------
news_type Varchar(15) yes ------------
Image Varchar(200) yes ------------
systemdatetime timestamp yes ------------

Table 3.1 - Store table

Field Type NULL Key


Id Int(11) No Primary Key
FirstName Varchar(200) yes ----------
LastName Varchar(200) yes ----------
Email_id Varchar(200) yes
Uname Varchar(200) yes ----------
Pwd Varchar(200) yes ----------
Rpwd Varchar(200) yes ----------
Gender Varchar(200) yes ----------
Phno Int(12) yes ----------

Table 3.2 – Table for registration and login:Newsportal


Field Type NULL Key
C_id Int(11) No ---------
Name Varchar(30) yes ----------
Loc Varchar(30) yes ----------
Email Varchar(30) yes ----------
Message Varchar(30) yes Primary Key

Table 3.3 Contact table


3.3 DFD For News Portal

Maintain
Account News Read News
News Portal
Administrator User
System
Updated Feedback
DFD – 1
CHAPTER 4
RESULT AND ANALYSIS

Online News Portal will provide the user flexibility to read the news online. Online news portal
will provide the users to give feedback. So that the admin can do changes according to the users
point of view. Here the users can read the news anywhere they are located and related to any
type. Here the news are available all the time.
Fig.4.15:Database for register and login page
Fig.4.18:Database for contact & feedback
Conclusion
 The online news portal provides the users flexibility.

 The online news portal overcome wastage of paper.

 The news are available for all the time.

 The users don’t wait for the newspaper to read the updated news.
Future Scope
As the project comes up with some limitations which can be improved in future and further more
advancement can also be done. The different features that can be added are as follows:
 Videos of different news can be provided related to various fields like Entertainment,
International, National, Sports, Business etc.
 Reader can be alerted through e-mail, cell phones or other devices about availability of
any new news of their interest.
 Readers can easily forward interesting news items to others.
 More fields can be added.
 Live support should be enabled
REFERENCES
1. Clarke, K.R. (2000) News Portal for Apparel Online Gains Popularity,
PricewaterhouseCoopers LLP.

2. CyberAltas Staff (2003), Online And Married With Cash, CyberAtlas Search,
<http://cyberatlas.internet.com/big_picture/demographics/print/0,,5901_3103421,00.html
>

3. Freedman, L.B (2002) It’s Just News Portal, The Direct Marketing Association, Inc.

You might also like