首页 >后端开发 >php教程 >php大规模数据提交的方法

php大规模数据提交的方法

墨辰丷
墨辰丷原创
2018-06-09 10:12:091426浏览

本篇文章主要介绍php大规模数据提交的方法,感兴趣的朋友参考下,希望对大家有所帮助。

本文实例讲述了PHP+JS实现大规模数据提交的方法,具体实现方法如下:

<?php 
session_start();
?>
<?php
if($_SESSION["login"] != "YES")
{
echo "<script languge=javascript> alert(&#39;您没有登录,无权访问,请先登录!&#39;);
location.href=&#39;index.php&#39;</script>";
}
?>
<!DOCTYPE html>
<html>
<!-- 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 == &#39;&#39; )
{ 
alert ("接收方号码不能全部为空!");
myform.focus();
return false;
}
if(myform.content.value == &#39;&#39;)
{
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>
<p id="container">
 <p id="head"> </p>
 <p 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>
 </p>
 <p id="crumbs">
短信管理 >>> 
<!-- InstanceBeginEditable name="EditRegion3" --> 
 发送短信  
 <!-- InstanceEndEditable --> </p>
 <p id="main"> 
 <!-- InstanceBeginEditable name="EditRegion1" -->
<?php require_once(&#39;connecting.php&#39;); ?>
<?php
//php代码
$content=$_POST["content"];
$msgto = $_POST["msgto"];
if( $content != &#39;&#39; && $msgto != &#39;&#39; ) {
$addtime = date("Y-m-d H:i:s");
//号码处理
$msg2 = trim( $msgto, &#39;,&#39;);
$msg2 = explode( &#39;,&#39;, $msg2 );
if( $msg2 ) {
foreach( $msg2 as $var ) {
$query = "insert into sendmessage(numbersend,timesend,contentsend,flagsend) 
values (&#39;$var&#39;,&#39;$addtime&#39;,&#39;$content&#39;,&#39;0&#39;)";
mysql_query( $query );
}
echo "<script languge=javascript> alert(&#39;记录成功,等待发送!&#39;); 
location.href=&#39;send_box.php&#39;</script>;";
} else {
echo "<script languge=javascript> alert(&#39;号码不对,请核对!&#39;); 
history.back(-1);</script>;";
}
}
?>
  <form method="post" name="myform" onsubmit="return checkdata();">
   <p 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>  号码为空!></option>>";
}
else
{
$totalnum = mysql_num_rows($result);
for( $i=0;$i <=$totalnum;$i++ )
{
$info = mysql_fetch_array( $result );
if($info != "")
{
echo "<option value=".$info[&#39;num&#39;]."><font color=blue ><b>".$info[&#39;name&#39;]."</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, &#39;Times New Roman&#39;, 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"><p align="center">
          <input type="submit" name="namesubmit" value="发送" />
         </p></td>
       </tr>
      </table></td>
    </tr>
   </table>
 </p>
   <input type="hidden" name="msgto" value="" />
  </form>
  <!-- InstanceEndEditable --> </p>
 <p id="footer"><br />
  ©2010  Designed By <cite></cite><img src="images/stone.gif" alt="石三" style="margin-left:15px; border:none;" /></a><br />
  <br />
 </p>
</p>
</body>
<!-- InstanceEnd -->
</html>

总结:以上就是本篇文的全部内容,希望能对大家的学习有所帮助。

相关推荐:

php针对数组的删除、转换、分组、排序

php针对字符串操作的方法

php模拟post请求的三种常见用法

以上是php大规模数据提交的方法的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn