.


:




:

































 

 

 

 


3

(), , , . . ' (, ). HTML php. MySQL. MySQL localhost ( Web- Apache). php MySQL php 䳿 MySQL. ϳ , 1 2 . , :
1.
2.
3.
4.
, , .
username MySQL. username sydorak.
sydorak:
> mysql -u root -p
Enter password:
Welcome to MySQL monitor. Commands end with; or \g.
Your MySQL connection id is 72 to server version: 3.22.32

Type 'help' for help.

mysql>use mysql;
Database changed

 

mysql> select * from user;
+-----------+-------+------------------+-------------+-------------+-----------+
| Host | User | Password | Select_priv |Insert_priv | Update_pri|
+-----------+-------+------------------+-------------+-------------+-----------+
| localhost | root | 3aa3ee1e1d77f653 | | | |
| l | root | | | | |
| localhost | | | N | N | N |
| l | | | N | N | N |
| localhost |sydorak| 75cbfbdb376c43a9 | N | N | N |
| localhost | admin | 12ad110a21defd86 | | | |
+-----------+-------+------------------+-------------+-------------+-----------+
6 rows in set (0.00 sec)

mysql>insert into user values ('localhost','sydorak',password('sydorak'),
-> 'y','y','y','y','y','n','y','n','n','n','n','n','n','n');
Query OK, 1 row affected (0.00 sec)
mysql> select * from user;
+-----------+--------+------------------+-------------+-------------+----------+
| Host | User | Password | Select_priv | Insert_priv | Update_pr|
+-----------+--------+------------------+-------------+-------------+----------+
| localhost | root | 3aa3ee1e1d77f653 | | | |
| l | root | | | | |
| localhost | | | N | N | N |
| l | | | N | N | N |
| localhost | alex | 75cbfbdb376c43a9 | N | N | N |
| localhost | admin | 12ad110a21defd86 | | | |
| localhost | sydorak| 7f6731414c9c046a | | | |
+-----------+--------+------------------+-------------+-------------+----------+
7 rows in set (0.00 sec)

mysql> quit
Bye
>
MySQL:
> mysqladmin -u root -p reload
Enter password:
>
----------------------------------------------------------------------------------
php. localhost.
sydorakdb1 ' sydoraktab1 ( !):
> mysql -u sydorak -p -h 'localhost'
Enter password:
Welcome to MySQL monitor. Commands end with; or \g.
Your MySQL connection id is 75 to server version: 3.22.32

Type 'help' for help.

mysql> create database sydorakdb1;
Query OK, 1 row affected (0.02 sec)

mysql> use sydorakdb1;
Database changed
mysql> create table sydoraktab1 (user_name VARCHAR(25),phone VARCHAR(10),
-> job BLOB,img VARCHAR(20));
Query OK, 0 rows affected (0.05 sec)

mysql> quit
Bye

username. ( ):
> mysqladmin -u sydorak -h 'localhost' -p password 'sydorak'
Enter password:
>
MySQL ( ):
> mysqladmin -u sydorak -h 'localhost' -p reload
Enter password: >


HTML :

index.html
<html>
<head>
<title>Menu</title>
</head>
<body>
<b>
< href="../php/form1.html">
1. </a><br>
< href="../php/form2.html">
2. ... </a><br>
< href="../php/form3.html">
3. </a><br>
< href="../php/form4.html">
4.³ </a>
</b>
<h5><p> :
<?PHP
$filename = "counter.dat";
$fp = fopen($filename,"r");
if ($fp) {
$counter=fgets($fp,10);
fclose($fp);
} else { $counter=0;
}
$counter++;
print $counter;
$fp = fopen($filename,"w");
if ($fp) {
$ii=fputs($fp,$counter);
fclose($fp);
}
?>
</h5>
</body>
</html>
counter.dat :
>chmod 0777 counter.dat

form1.html
<html>
<head>
<title>form1</title>
<body>
<form method=post action="form1.php">
<br><b> ':</b>
<br><input name="user_name" value="" size=30>
<br><br><b> :</b>
<br><input name="phone" value="" size=10>
<br><br><b> :
<br><TEXTAREA NAME="job" ROWS=10 COLS=40></TEXTAREA>
<br><br><b> ' .:</b>
<br><input name="img" value="nofoto.jpg" size=20>
<br><br><input type="submit" value="">
</form>
</body>
</html>

form2.html
<html>
<head>
<title> </title>
<body>
<form action="form2.php" method="post">
<b> ...<b>
<input type="text" name="user_name" size=30>
<input type="submit" value="!">
</form>
</body>
</html>

form3.html
<html>
<head>
<title> </title>
<body>
<form action="form3.php" method="post">
<b> ... :<b>
<input type="text" name="user_name" size=30>
<input type="submit" value="!">
</form>
</body>
</html>

form4.html
<html>
<head>
<title> </title>
<body>
<form action="form4.php" method="post">
<b> ... , :<b>
<br><input type="text" name="user_name" size=30>
<input type="submit" value="!">
</form>
</body>
</html>

P:

form1.php
<?
/* */
$hostname="localhost";
$username="sydorak";
$password="sydorak";
/* ' */
$dbName="sydorakdb";
/* MySQL */
$usertable="sydoraktab1";
/* ' */
MYSQL_CONNECT($hostname,$username,$password) OR DIE(" '");
/* */
MYSQL_SELECT_DB($dbName) or die(" ");
/* */
$query="INSERT INTO $usertable VALUES ('$user_name','$phone','$job','$img')";
$result=MYSQL_QUERY($query);
/* ' */
MYSQL_CLOSE();
print " ! <br>";
print "<a href='../php/'> </a>";
?>

form2.php
<?php
$hostname="localhost";
$username="sydorak";
$password="sydorak";
$dbName="sydorakdb";
$usertable="sydoraktab1";
mysql_connect($hostname,$username,$password) or die(" ' ");
mysql_select_db("$dbName") or die(" ");
/* , $usr_name */
$query="select * from $usertable where user_name like '$user_name%'";
$result=mysql_query($query);
/* ? */
$number=mysql_numrows($result);
/* */
$i=0;
if ($number == 0)
{
{
print " $user_name <br>";
}
elseif ($number > 0)
{
while ($i < $number)
{
/* user_name, phone, job, img i-
*/
$user_name=mysql_result($result,$i,"user_name");
$phone=mysql_result#@:;
$job=mysql_result#@;;
$img=mysql_result#@

form3.php
<?php
$hostname="localhost";
$username="sydorak";
$password="sydorak";
$dbName="sydorakdb";
$usertable="sydoraktab1";
mysql_connect($hostname,$username,$password) or die(" ' ");
mysql_select_db("$dbName") or die(" ");
/* user_name */
$query="delete from $usertable where user_name='$user_name'";
$result=mysql_query($query);
print " <br>";
print "<a href='../php/'> </a>";
?>

form4.php
<?php
$hostname="localhost";
$username="sydorak";
$password="sydorak";
$dbName="sydorakdb";
$usertable="sydoraktab1";
mysql_connect($hostname,$username,$password) or die(" ' ");
mysql_select_db("$dbName") or die(" ");
/* user_name */
$query="select * from $usertable where user_name='$user_name'";
$result=mysql_query($query);
/* */
$number=mysql_numrows($result);
if ($number==0)
{
print " !<br>";
print "<a href='../php/'> </a>";}
else
{
/* ,
*/
$phone=mysql_result($result,0,"phone");
$job=mysql_result($result,0,"job");
$img=mysql_result($result,0,"img");
print "<img src='pics/$img' height=130><br>";
/* */
$query="delete from $usertable where user_name='$user_name'";
$result=mysql_query#@:;
/* */
print "<form method=post action='form5.php'>";
print "<br><b> ':</b>";
print "<br><input name='user_name' value='$user_name' size=30>";
print "<br><br><b> :</b>";
print "<br><input name='phone' value='$phone' size=10>";
print "<br><br><b> :";
print "<br><TEXTAREA NAME='job' ROWS=10 COLS=40>$job</TEXTAREA>";
print "<br><br><b> ' .:</b>";
print "<br><input name='img' value='$img' size=20>";
print "<br><br><input type='submit' value=''>";
print "</form>";
}
?>

form5.php
<?
/* */
$hostname="localhost";
$username="sydorak";
$password="sydorak";

/* ' */
$dbName="sydorakdb";

/* MySQL */
$usertable="sydoraktab1";

/* ' */
mysql_connect($hostname,$username,$password) or die(" ' ");

/* */
mysql_select_db("$dbName") or die(" ");

/* */
$query="INSERT INTO $usertable VALUES ('$user_name','$phone','$job','$img')";
$result=MYSQL_QUERY($query);
/* ' */
MYSQL_CLOSE();
print " ! <br>";
print "<a href='../php/'> </a>";
?>


 

 



<== | ==>
2. |
:


: 2016-03-26; !; : 252 |


:

:

, .
==> ...

1728 - | 1513 -


© 2015-2024 lektsii.org - -

: 0.018 .