-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbjsubmit.php
121 lines (99 loc) · 3.12 KB
/
bjsubmit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<html>
<head></head>
<body>
<div style="background-image:url(http://localhost/php/images/111.gif);">
<?php
require "function.php";
session_start();
if(!(isset($_SESSION['islogin'])&&$_SESSION['islogin']=="success"))
{
alert("你敢跳墙我好怕怕","back");
exit;
}
echo "欢迎您".$_SESSION['username'];
echo "<a href='http://localhost/php/bjxx.php'>添加</a>";
echo "<a href='http://localhost/php/bjexit.php'>退出</a>";
$link=mysql_connect('localhost','root','') or die ('jjj');
$db=mysql_select_db('testdb',$link);
if($_POST != NUll)
{
$id=$_POST["id"];
$name = $_POST["name"];
$gender = $_POST["gender"];
$birthday=$_POST["birthday"];
$phone = $_POST["phone"];
$qq = $_POST["qq"];
$address = $_POST["address"];
$words = $_POST["words"];
$imageName = "";
$imagePath = "";
if($_FILES['wenjian']['error'] != 4)
{
$file = $_FILES['wenjian'];
if ($file['error'] == 0) {
$size = $file['size'];
$type = $file['type'];}
if ($size > 20 * 1024 ) {
die("尺寸过大");
}
if ($type != 'image/jpeg' && $type != 'image/png'&& $type != 'image/gif') {
die("请上传图片");
}
$tmpInfo = pathinfo($file['tmp_name']);
$imgInfo = pathinfo($file['name']);
$fileName = $tmpInfo['filename'] . "." . $imgInfo['extension'];
$imagePath = "/uploads/" . $fileName;
$imageName = $file['name'];
move_uploaded_file($file['tmp_name'], "E:\wamp\wamp\www\\$imagePath");
}
$res=mysql_query("insert into txxx values('$id','$name','$gender','$birthday',
'$phone','$qq','$address',' $words','$imagePath', '$imageName')"); //数据插入
}
/*分页*/
$page=isset($_GET['page']) ? $_GET['page'] : 1;
$rows=5;
$offset=($page-1) * $rows;
$link=mysql_connect('localhost','root','') or die ('jjj');
$db=mysql_select_db('testdb',$link);
$sql="select count(*) as count from txxx";
$result=mysql_query($sql);
$arr=mysql_fetch_array($result,MYSQL_ASSOC);
//print_r($arr);
$total=$arr['count'];
$pages=ceil($total/$rows);
if($page>$pages){
alert("您的输入页数不存在,请正确输入","back");
exit;
}
$sql="select * from txxx limit $offset,$rows";
$result=mysql_query($sql);
if($result){
$array=array();
while ($arr=mysql_fetch_array($result,MYSQL_ASSOC))
{
$array[]=$arr;
}
}
else
{
die(mysql_error());
}
display1($array);
/* $result=mysql_query("select * from txxx ");// 调用数据库内容
if($result){
$array=array();
while ($arr=mysql_fetch_array($result,MYSQL_ASSOC))
{
$array[]=$arr;kkk
} echo "添加成功";
}
else
{
die(mysql_error());
}
display1($array);*/
require "bj.html ";
?>
<div>
</body>
</html>