You are on page 1of 20

Web Programming for

Dummies

tutorial,
.
.A
,
,
(, , php programming),
.
.
,
. tutorial
,
walkthrough , HTML,PHP
.

Starting Up:
site wamp/xamp
server, apache .
skype ,
skype port 80.
(
Power Designer 16.5).

wamp ,
localhost, browser index.php
C/wamp/www/ . ,
.

wamp -> phpmyadmin


server. ,
import.

:
Power Designer. New->Conceptual Data.
(entities) , ,
.
entity, attributes .
datatype. varchar,
length.
Auto Increment id,
. P
(Primary Key). attribute (,
)
Primary Key( ),
M (Mandatory=).
,
mandatory, , 2
( Primary Key).

, ,
.

, ,
. relationship
,
. drag n drop conceptual diagram
, 2 .
, ->Cardinalities.

.
,

.
One-Many.

Cardinalities
. ,
( 0 n).
, 1
1 . ,
, mandatory.

HTML: HyperText Markup Language


- ( ,
, ,
)
- Markup : HTML
tags, (element)
markup
- browser (client-side)
- , (
)

Server Client

url browser ,
browser ,
. HTML ,
browser. browser HTML ,
, . ,
browser client, Server.

, :
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>

, (My First Heading


My first paragraph) tags
, .

, ,
,
:

PHP: PHP HyperText Preprocessor


-
- Server(Server-Side)
- Web Design,
- HTML

, HTML, PHP server.


?

browser PHP , browser PHP


. Server, ,
html , browser.

, ,
11:00 , .
HTML
,
refresh .

, PHP ,

:

Figure 1 tag php PHP HTML

: Server , client ,
server.
client,

javascript( client side )

View Page Code ,


HTML , PHP:

, PHP / HTML
.
, (
, ) HTML.
, PHP.

HTML tags :
: browser HTML5
( HTML )
<!DOCTYPE html>

<html> </html>
<body> </body>

<head > </head>


client
server: register .

textboxes . , server,
, .
Form

action : url

method = {get, post}:


get : query url

post : http

GET, youtube.
search, Url browser. ,
client server
( ),
GET . ,
search ( bookmarked)
, server ,
POST. , ,

server . ,
Login .
url,
server.

server,
Superglobal $_POST $_GET*,
form action. ,
register.php register, form
action aek.php
.

Register.php
form method="POST" action="aek.php">
Username: <input type="text" name="username/><br />
Password: <input type="password" name="password" /><br />
<p><input type="submit" value="Login" /></p>
</div>
</form>

Aek.php
echo $_POST[username];
echo $_POST[password];

Sessions
Session
.
. ,
facebook .
HTTP Stateless[ server ],
,
client (cookies/HTML5 Web Storage) server(Sessions).
, Sessions.
M Server superglobal
$_SESSION. Session,
,
session_start(); . ,
,
Login.php
Session_start();
If ($admin_stat==1) //ean h metavlhth sthn opoia apothikevoume ta
//dikaiwmata tou kathe xrhsth einai 1, tote
$_SESSION[admin]=1;
//tha
kanoume
ton
xrhsth
diaxeiristh

Yolo.php
Session_start();
If (isset($_SESSION[admin]) && ($_SESSION[admin]==1) echo aek;
//ean h metavlhth SESSION admin exei tethei, kai einai 1, tote emfanise
aek

login.php admin,
, Session admin 1.
, ,
,
yolo.php

Session,
unset() session_destroy() .

SQL Queries

sql queries php.

, .
,
,
include .

<?php
// Create connection
$con=mysqli_connect("localhost","admin","","test");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>

$con
. sql query ,
.
mysqli_connect :
Host : localhost,
www.example.com
Username: default wamp admin
Password: default wamp .
Dbname: ,

,
phpmyadmin, ,
server .

, query .
kostas.
$query_name = SELECT *
FROM pinakas_xristwn
WHERE onoma=kostas;

, mysqli_query
query $query_name.
$result=mysqli_query($con,$query_name);

result
select.
,
mysqli_fetch_array. mysqli_fetch_array,
row $result.
, while .
while($row = mysqli_fetch_array($result))
{
echo $row[username'];
}

echo $row[username']
. ,
$result, username, onoma, hlikia,
$row[username'], $row[onoma], $row[hlikia]
.

while
$row = mysqli_fetch_array($result);
echo $row[username'];

.
:
1.
mysql_query mysqli_query. ,
(mysqli=mysql Improved) mysql_query.
mysqli.
2.
,

mysqli_fetch_row, mysqli_fetch_assoc.
3.
( php).
4. extract($row) , while,
, . ,

while($row = mysqli_fetch_array($result))
{
extract($row);
echo $username;
echo $onoma;
echo $hlikia;
}

JavaScript

scripting language

HTML
Internet browser (Client Side)
Java,

X JavaScript:

.. link
html elements

submit
javascript:
http://www.w3schools.com/js/tryit.asp?filename=tryjs_lightbulb

changeImage() .

document.getElementById. , html
id ('myImage')
. ,
.
,
.
id onclick="changeImage()",

.

///
mavroforos@ceid.upatras.gr
gkofas@ceid.upatras.gr

You might also like