服务器之家:专注于服务器技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|JAVA教程|ASP教程|编程技术|正则表达式|C/C++|

服务器之家 - 编程语言 - PHP教程 - PHP+JS实现大规模数据提交的方法

PHP+JS实现大规模数据提交的方法

2020-10-29 15:33tianmo2010 PHP教程

这篇文章主要介绍了PHP+JS实现大规模数据提交的方法,以一个短信群发系统实例分析了php大规模数据提交的相关技巧,需要的朋友可以参考下

本文实例讲述了PHP+JS实现大规模数据提交的方法。分享给大家供大家参考。具体实现方法如下:

 
?
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<?php
session_start();
?>
<?php
if($_SESSION["login"] != "YES")
{
echo "<script languge=javascript> alert('您没有登录,无权访问,请先登录!');
location.href='index.php'</script>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- InstanceBegin template="/Templates/tmplet.dwt.php"
codeOutsideHTMLIsLocked="true" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>短信群发管理系统</title>
<link type="text/css" rel="stylesheet" href="style/style.css" />
<!-- InstanceBeginEditable name="EditRegion2" -->
<script type="text/javascript" src="lib/jquery.js"></script>
<script type="text/javascript" src="lib/maxlength.js"></script>
<script language="JavaScript" type="text/javascript">
<!--
function checkdata()
{
if( myform.msgto.value == '' )
{
alert ("接收方号码不能全部为空!");
myform.focus();
return false;
}
if(myform.content.value == '')
{
alert ("短消息内容不能为空!");
myform.focus();
return false;
}
}
function moveOption1(e1, e2){
 try{
 for(var i = 0; i < e1.options.length; i++){
  if( e1.options[i].selected ){
  var e = e1.options[i];
e2.options.add(new Option(e.text, e.value));
  e1.remove(i);
  i = i - 1;
  }
 }
 document.myform.msgto.value=getvalue(document.myform.list2);
 }
 catch(e){}
}
function moveOption2(e1, e2){
 try{
 for(var i = 0; i < e1.options.length; i++){
  if(e1.options[i].selected ){
  var e = e1.options[i];
e2.options.add(new Option(e.text, e.value));
  e1.remove(i);
  i = i - 1;
  }
 }
 document.myform.msgto.value=getvalue(document.myform.list2);
 }
 catch(e){}
}
function getvalue(geto){
var allvalue = "";
for(var i=0;i<geto.options.length;i++){
allvalue +=geto.options[i].value + ",";
}
return allvalue;
}
function moveAllOption1(e1, e2){
 try{
 for(var i = 0;i < e1.options.length; i++){
  var e = e1.options[i];
  e2.options.add(new Option(e.text, e.value));
  e1.remove(i);
  i = i - 1;
 }
 document.myform.msgto.value=getvalue(document.myform.list2);
 }
 catch(e){
 }
}
function moveAllOption2(e1, e2){
 try{
 for(var i = 0;i < e1.options.length; i++){
  var e = e1.options[i];
  e2.options.add(new Option(e.text, e.value));
  e1.remove(i);
  i = i - 1;
 }
 document.myform.msgto.value=getvalue(document.myform.list2);
 }
 catch(e){
 }
}
-->
</script>
<!-- InstanceEndEditable -->
</head>
<body>
<div id="container">
 <div id="head"> </div>
 <div id="menu">
  <ul>
   <li id="first_li"><a href="group.php">发送短信</a></li>
   <li><a href="send_box.php">发件箱</a></li>
   <li><a href="recv_box.php">收件箱</a></li>
   <li><a href="mynumber.php">管理电话薄</a></li>
   <li><a href="autoreply.php">添加自动回复</a></li>
   <li><a href="autoreply_ctl.php">管理自动回复</a></li>
   <li><a href="toadmin.php">联系管理员</a></li>
   <li><a href="logout.php">注销</a></li>
  </ul>
 </div>
 <div id="crumbs">
短信管理 &gt;&gt;&gt;
<!-- InstanceBeginEditable name="EditRegion3" -->
 发送短信 
 <!-- InstanceEndEditable --> </div>
 <div id="main">
 <!-- InstanceBeginEditable name="EditRegion1" -->
<?php require_once('connecting.php'); ?>
<?php
//php代码
$content=$_POST["content"];
$msgto = $_POST["msgto"];
if( $content != '' && $msgto != '' ) {
$addtime = date("Y-m-d H:i:s");
//号码处理
$msg2 = trim( $msgto, ',');
$msg2 = explode( ',', $msg2 );
if( $msg2 ) {
foreach( $msg2 as $var ) {
$query = "insert into sendmessage(numbersend,timesend,contentsend,flagsend)
values ('$var','$addtime','$content','0')";
mysql_query( $query );
}
echo "<script languge=javascript> alert('记录成功,等待发送!');
location.href='send_box.php'</script>;";
} else {
echo "<script languge=javascript> alert('号码不对,请核对!');
history.back(-1);</script>;";
}
}
?>
  <form method="post" name="myform" onsubmit="return checkdata();">
   <div style=" padding-bottom:20px;">
 <table border="0" width="100%" style="">
    <tr>
     <td bgcolor="#3399CC"  width="13%"><select style="width:100%;" multiple name="list1" size="15" ondblclick="moveOption1(document.myform.list1, document.myform.list2)">
<?php
$query = "select * from `number`";
$result = mysql_query( $query );
if( mysql_num_rows( $result ) < 1 )
{
echo "<option> &nbsp;号码为空!></option>>";
}
else
{
$totalnum = mysql_num_rows($result);
for( $i=0;$i <=$totalnum;$i++ )
{
$info = mysql_fetch_array( $result );
if($info != "")
{
echo "<option value=".$info['num']."><font color=blue ><b>".$info['name']."</b></font></option><br>";
}
}
}//else
mysql_close($member);
?>
      </select>
     </td>
     <td width="10%" align="center"><input type="button" value="添加" onClick="moveOption1(document.myform.list1, document.myform.list2)">
      <br>
      <br>
      <input type="button" value="全选" onClick="moveAllOption1(document.myform.list1, document.myform.list2)">
      <br>
      <br>
      <input type="button" value="删除" onClick="moveOption2(document.myform.list2, document.myform.list1)">
      <br>
      <br>
      <input type="button" value="全删" onClick="moveAllOption2(document.myform.list2, document.myform.list1)">
     </td>
     <td bgcolor="#3399CC" width="13%"><select style="width:100%;" multiple name="list2" size="15" ondblclick="moveOption2(document.myform.list2, document.myform.list1)">
      </select>
     </td>
     <td><table rules="none" align="center" cellpadding="1" cellspacing="10" border="0" >
       <tr bgcolor="">
        <td height="23" align="left" style="font-size:120%;"> 请将短信内容限制在70字以内。当前字数:
 <span id="status1" style="width:30px;font-weight:bold;text-align:right; font-size:150%; font-family:Georgia, 'Times New Roman', Times, serif">
 </span></td>
       </tr>
       <tr>
        <td>
<textarea name="content" style="width:350px; height:120px; font-size:150%;" data-maxsize="70" data-output="status1" wrap="virtual"></textarea>
</td>
       </tr>
       <tr>
        <td height="24"><div align="center">
          <input type="submit" name="namesubmit" value="发送" />
         </div></td>
       </tr>
      </table></td>
    </tr>
   </table>
 </div>
   <input type="hidden" name="msgto" value="" />
  </form>
  <!-- InstanceEndEditable --> </div>
 <div id="footer"><br />
  &copy;2010  Designed By <cite></cite><img src="images/stone.gif" alt="石三" style="margin-left:15px; border:none;" /></a><br />
  <br />
 </div>
</div>
</body>
<!-- InstanceEnd -->
</html>

希望本文所述对大家的php程序设计有所帮助。

延伸 · 阅读

精彩推荐