Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

ПрактикаWEB_2

.pdf
Скачиваний:
8
Добавлен:
09.02.2016
Размер:
356.18 Кб
Скачать

$data['username'] = $username; $data['password'] = md5($password); //

$data['email'] = $email;

)

$newUser = new User($data);

)

$newUser ->save(true);

//

$userTools ->login($username, $password);

//

header("Location: welcome.php");

}}

) '

?>

<html>

<head>

<title>Registrationtitle>

head>

<body>

<form action="register.php" method="post">

Username: <input type="text" value="" name="username" /><br/> Password: <input type="password" value="" name="password" /><br/>

Password (confirm) : <input type="password" value="" name="password-confirm" /><br/> E - Mail: <input type="text" value="" name="email" /><br/>

<input type="submit" value="Register" name="submit-form" /> form>

body>

html>

A DC

 

(

 

 

dW[efWd(bb

 

RGF

(

 

 

 

 

$geWdS_W'bSeeiadV(%(

'

 

 

(

'

'

 

 

'

 

 

(

 

 

 

 

 

'

Wdad(

 

'

 

(

 

 

RGF

 

 

 

 

A G GF (

 

 

RGF

(

 

 

 

(

RGF PegT_[f-

ad_Q

[eeWf$%'

egT_[f- or_

(

 

'

 

'

(

 

LeWdaae

 

 

(

'

egUUWee SeW

 

Wdad(

-

 

'

 

(

 

 

'

 

VSfS

 

 

LeWd(

 

eShW$%

LeWd

$isNewUser - fdgW(

 

 

a[$%

 

welcome.php.

iWUa_W(bb

<html>

<head>

<title>Welcome username; ?>title> head>

<body>

Hey there, username; ?>. You've been registered and logged in.

Welcome! <a href="logout.php">Log Outa> | <a href="index.php">Return to Homepagea>

body>

html>

login.php

 

 

 

dW[efWd(bb'a[(bb

(

 

(

(

login($username, $password)){

 

)

'

 

header("Location: index.php"); }else{

$error = "Incorrect username or password. Please try again".;

}

}

?>

<html>

<head>

<title>Logintitle>

head>

<body>

<br/>";

}

?>

<form action="login.php" method="post">

Username: <input type="text" name="username" value="" /><br/>

Password: <input type="password" name="password" value="" /><br/> <input type="submit" value="Login" name="submit-login" />

form>

body>

html>

logout.php

.

A DC(

aagf$%(

(

4

 

//logout.php

 

require_once 'includes/global.inc.php';

 

$userTools = new UserTools();

 

$userTools ->logout();

 

header("Location: index.php");

 

?>

 

'

(

'

(

(

 

 

(

 

 

 

LeWd

(

 

eShW$%

(

 

 

email;

 

 

 

$message = "";

 

 

 

)

 

 

 

if(isset($_POST['submit - settings'])){

 

 

//

$_POST

 

 

$email = $_POST['email'];

 

 

$user ->email = $email;

 

 

$user ->save();

 

 

 

$message = "Settings Saved<br/>";

 

 

}

 

 

 

)

 

-

 

?>

 

 

 

<html>

 

 

 

<head>

 

 

 

<title>Change Settingstitle>

 

 

head>

 

 

 

<body>

 

 

 

<form action="settings.php" method="post">

 

 

E - Mail: <input type="text" value="" name="email" /><br/>

 

<input type="submit" value="Update" name="submit-settings" />

 

form>

 

 

 

body>

 

 

 

html>

 

 

 

 

- index.php

 

 

 

(

-

(

 

 

'

(

 

'

(

 

<html>

<head>

<title>Homepagetitle>

head>

<body>

Hello, username; ?>. You are logged in. <a href="logout.php">Logouta> | <a href="settings.php">Change Emaila>

You are not logged in. <a href="login.php">Log Ina> | <a href="register.php">Registera> body>

html>

 

4

+-

 

-

 

-

 

-

4=;(USee(bb

,-

U

-

$LeWd%

-

LeWdaas

-

\ \

-

 

-

 

-

 

-

 

1.

HC(

2.

GAG(

3.DkHC(

4.

GAG

DkHC(

5.mysql_connect().

6.mysql_pconnect().

1(

V[W$%(

 

 

 

 

 

 

 

 

 

6.2 - 4 4

c

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

22 (

)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

bbDk:V_[(

1.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

5.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1.

 

 

 

 

 

- pGAG HgWdk

 

 

q'

',++ ' . (

 

 

 

2.

 

 

 

- p

 

 

 

 

 

q'

4

 

', + ',22

(

 

 

3.

 

'

 

 

 

 

web -

 

 

 

 

GAG Dkc '

-

-

 

 

' ,

 

(

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

FM:I 4

 

 

 

 

 

 

 

 

 

 

 

 

1.

 

 

 

fahSd'

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1

 

 

id

 

 

 

 

-

 

 

 

 

 

 

 

INT

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2

 

 

name

 

 

 

 

 

 

 

 

 

 

 

VARCHAR (20)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3

 

 

cost

 

 

 

 

 

 

 

 

 

 

 

INT

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4

 

 

kol

 

 

 

 

 

 

 

 

 

 

 

INT

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

5

 

 

date

 

 

 

 

 

 

 

 

 

 

 

DATE

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

id

 

name

 

 

 

cost

 

kol

 

date

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1

 

 

 

 

 

24

 

100

 

25.03.10

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2

 

 

 

 

 

20

 

50

 

 

27.03.10

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

SELECT column1,. FROM table WHERE definition ORDER BY col_name

 

 

 

 

 

 

 

 

:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

INSERT INTO table VALUES (value1, .)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

DELETE FROM table WHERE definition

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

DkHC4

 

 

 

 

 

 

 

 

 

 

 

 

int mysql_connect(string hostname, string

username,

string password)

-

'

MySQL.

 

 

 

 

 

 

int,

0,

'

 

 

 

,

0

.

hostname -

 

 

 

'

 

 

 

 

 

(

 

 

 

 

 

 

 

 

 

Username -

 

(

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Password -

 

 

 

 

(

 

 

 

 

 

 

 

 

 

 

 

 

 

 

int mysql_select_db(string database_name, int link_identifier) -

 

 

 

 

 

 

.

 

 

 

 

 

 

true

false

 

 

 

 

 

 

 

 

 

 

 

 

Database_name - '

 

.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

link_identifier - ID

'

,

 

 

 

 

mysql_connect. $

 

 

 

'

 

 

 

 

'

 

 

 

 

B=

 

 

 

_kecRUa WUf%

 

 

 

int mysql_query(string query, int link_identifier) -

 

 

 

 

.

 

 

 

ID

0,

 

 

 

.

 

 

 

 

 

 

 

 

 

 

 

query -

,

 

 

link_identifier - .

 

 

 

.

 

 

 

 

 

 

int mysql_result(int result, int i, column) -

 

 

 

 

 

 

 

 

column

 

i.

int mysql_close(int link_identifier) -

'

MySQL.

true

false.

 

 

 

 

link_identifier -

.

 

 

 

 

phpMyAdmin :

 

localhost

phpMyAdmin.

 

 

a_WgeWd

(

 

 

 

FM:I-

$<dWSfW=SfSTSeW%

 

 

fah4

 

 

 

xfah5

-/5

(

 

(

 

SgfaR[UdW_Wf$

%(

bd[_Sdk]Wk$

%(

(

.

 

(

 

ST.(

[VWj(bb'

(

 

 

 

 

 

 

 

 

4

 

 

 

 

 

<?php

 

 

 

 

 

WUa 6+8

6)+86Td85

 

 

 

echo "6fSTWTadVWd7+86fdS[ 7UWfWd86fVi[Vf7+!86T8

6)fV86fVi[Vf7 !86T8 6)fV86fV

i[Vf7,!86T8 6)fV86fVi[Vf7,!86T8

6)fV86fVi[Vf7,!86T8

6)fV86)fd85

$sqlhost="localhost"; $sqluser="homeuser"; $sqlpass=""; $bd="TOVARS";

 

// '

 

 

 

 

 

mysql_connect($sqlhost,$sqluser,$sqlpass) or die ("

 

"!.mysql_error());

 

//

 

 

 

 

 

mysql_select_db($bd) or die ("

'

".mysql_error());

 

 

$zap="SELECT * FROM tovar ORDER BY id";

) HC- $zap_res=mysql_query($zap);

while (list($id, $name, $cena, $kol, $prim)=mysql_fetch_row($zap_res))

{

echo "<tr>

 

<td>$id</td> <td>$name</td> <td> $cena</td>

<td>$kol</td> <td>$prim</td> </tr>";}

echo "</table>"; ?>

 

,

'

(

 

[eWdf(bb'

(

:

 

<?php

 

if (isset($_REQUEST))

 

{

 

foreach($_REQUEST as $key=>$val)

 

{$key=$val;}

 

}

 

$sqlhost="localhost"; $sqluser="homeuser"; $sqlpass=""; $bd="TOVARS";

mysql_connect($sqlhost,$sqluser,$sqlpass) or die ("

"!.mysql_error());

mysql_select_db($bd) or die ("

'

".mysql_error());

 

$zap="INSERT INTO tovar( name, cost, kol, prim) VALUES ($name, $cena, $kol, $prim)";

$zap_res=mysql_query($zap);

 

 

 

if (zap_res==true)

 

 

 

echo "

"; else

echo "

";?>

VWWfW(bb'

 

 

(

:

<?php

if (isset($_REQUEST))

{

$num=$_REQUEST[num];

}

$sqlhost="localhost"; $sqluser="homeuser"; $sqlpass=""; $bd="TOVARS";

mysql_connect($sqlhost,$sqluser,$sqlpass) or die ("

"!.mysql_error());

mysql_select_db($bd) or die ("

'

".mysql_error());

 

$zap="DELETE FROM 'tovar' WHERE id = $num ";

 

$zap_res=mysql_query($zap);

 

 

 

if (zap_res==true)

 

 

 

 

echo "

 

";

 

 

WeWWUa

 

 

598

 

1.

HC(

 

 

2.

 

 

GAG(

 

3.DkHC(

4.

GAG

DkHC(