我的代码工作正常,但问题是我无法使用相同的用户ID插入数据。就像我只能在行中添加userid一样的行 - 我如何插入具有相同行的数据?
我无法在下一行添加相同的内容,例如userid = 1 email = test@test.com message = hello。
就像我从userid 1发送的消息是= hello和email = hassan@test.com,但是当我再次使用不同的消息发送它时,它没有插入数据库并发送上一条消息。
<?php
//mysqli connectivity, select database
$connect= new mysqli("localhost","root","","demo") or die("ERROR:could not connect to the database!!!");
//extract all html field
extract($_POST);
if(isset($save))
{
//store textarea values in <pre> tag
$msg="$a";
//insert values in textarea table
$query="insert into textarea values('','$e','$msg')";
$connect->query($query);
echo "Data saved";
$query1="select * from textarea";
$result=$connect->query($query1);
while($row=$result->fetch_array())
{
$email = $row['email'];
$message1 =$row['message'];
}
$type = "xml";
$tos = preg_replace('#\s+#',',',trim($email));
$id = "id";
$pass = "pass";
$lang = "English";
$mask = "VOGUE";
// Data for text message
$to = "$tos";
$message = "$message1";
// Prepare data for POST request
$data = "id=".$id."&pass=".$pass."&msg=".$message."&to=".$to."&lang=".$lang."&mask=".$mask."&type=".$type;
// Send the POST request with cURL
$ch = curl_init('http://www.outreach.pk/api/sendsms.php/sendsms/url');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch); //This is the result from Outreach
curl_close($ch);
}
?>
<html>
<head>
<style>
input,textarea{width:250px}
textarea{height:200px}
input[type=submit]{width:150px}
</style>
<!--
* @Package: Ultra Admin - Responsive Theme
* @Subpackage: Bootstrap
* @Version: 1.0
* This file is part of Ultra Admin Theme.
-->
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<meta charset="utf-8" />
<title> Admin : Sms Send</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta content="" name="description" />
<meta content="" name="author" />
<link rel="shortcut icon" href="assets/images/favicon.png" type="image/x-icon" /> <!-- Favicon -->
<link rel="apple-touch-icon-precomposed" href="assets/images/apple-touch-icon-57-precomposed.png"> <!-- For iPhone -->
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/images/apple-touch-icon-114-precomposed.png"> <!-- For iPhone 4 Retina display -->
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/images/apple-touch-icon-72-precomposed.png"> <!-- For iPad -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/images/apple-touch-icon-144-precomposed.png"> <!-- For iPad Retina display -->
<!-- CORE CSS FRAMEWORK - START -->
<link href="assets/plugins/pace/pace-theme-flash.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/fonts/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/animate.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/perfect-scrollbar/perfect-scrollbar.css" rel="stylesheet" type="text/css"/>
<!-- CORE CSS FRAMEWORK - END -->
<!-- OTHER SCRIPTS INCLUDED ON THIS PAGE - START -->
<!-- OTHER SCRIPTS INCLUDED ON THIS PAGE - END -->
<!-- CORE CSS TEMPLATE - START -->
<link href="assets/css/style.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/responsive.css" rel="stylesheet" type="text/css"/>
<!-- CORE CSS TEMPLATE - END -->
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class=" ">
<!-- START TOPBAR -->
<div class='page-topbar '>
<div class='logo-area'>
</div>
</div>
<!-- END TOPBAR -->
<!-- START CONTAINER -->
<div class="page-container row-fluid">
<!-- SIDEBAR - START -->
<div class="page-sidebar ">
<!-- MAIN MENU - START -->
<?php include('header.php'); ?>
<!-- MAIN MENU - END -->
</div>
<!-- SIDEBAR - END -->
<!-- START CONTENT -->
<section id="main-content" class=" ">
<section class="wrapper" style='margin-top:60px;display:inline-block;width:100%;padding:15px 0 0 15px;'>
<div class='col-lg-12 col-md-12 col-sm-12 col-xs-12'>
<div class="page-title">
<div class="pull-left">
<h1 class="title">Form Validations</h1> </div>
</div>
</div>
<div class="clearfix"></div>
<div class="col-lg-6">
<section class="box ">
<header class="panel_header">
<h2 class="title pull-left">Message Validations</h2>
</header>
<form method="post">
<table width="200" border="1">
<tr>
<td>Email</td>
<td><textarea type="text" name="e" /></textarea></td>
</tr>
<tr>
<td>Message</td>
<td><textarea placeholder="contents" name="a"></textarea></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Save" name="save"/>
<input type="submit" value="Display" name="disp"/>
</td>
</tr>
</table>
</form>
</section></div>
</section>
</section>
<!-- END CONTENT -->
<div class="page-chatapi hideit">
<div class="search-bar">
<input type="text" placeholder="Search" class="form-control">
</div>
<div class="chat-wrapper">
<h4 class="group-head">Groups</h4>
<ul class="group-list list-unstyled">
<li class="group-row">
<div class="group-status available">
<i class="fa fa-circle"></i>
</div>
<div class="group-info">
<h4><a href="#">Work</a></h4>
</div>
</li>
<li class="group-row">
<div class="group-status away">
<i class="fa fa-circle"></i>
</div>
<div class="group-info">
<h4><a href="#">Friends</a></h4>
</div>
</li>
</ul>
<h4 class="group-head">Favourites</h4>
<ul class="contact-list">
<li class="user-row" id='chat_user_1' data-user-id='1'>
<div class="user-img">
<a href="#"><img src="data/profile/avatar-1.png" alt=""></a>
</div>
<div class="user-info">
<h4><a href="#">Clarine Vassar</a></h4>
<span class="status available" data-status="available"> Available</span>
</div>
<div class="user-status available">
<i class="fa fa-circle"></i>
</div>
</li>
<li class="user-row" id='chat_user_2' data-user-id='2'>
<div class="user-img">
<a href="#"><img src="data/profile/avatar-2.png" alt=""></a>
</div>
<div class="user-info">
<h4><a href="#">Brooks Latshaw</a></h4>
<span class="status away" data-status="away"> Away</span>
</div>
<div class="user-status away">
<i class="fa fa-circle"></i>
</div>
</li>
<li class="user-row" id='chat_user_3' data-user-id='3'>
<div class="user-img">
<a href="#"><img src="data/profile/avatar-3.png" alt=""></a>
</div>
<div class="user-info">
<h4><a href="#">Clementina Brodeur</a></h4>
<span class="status busy" data-status="busy"> Busy</span>
</div>
<div class="user-status busy">
<i class="fa fa-circle"></i>
</div>
</li>
</ul>
<h4 class="group-head">More Contacts</h4>
<ul class="contact-list">
<li class="user-row" id='chat_user_4' data-user-id='4'>
<div class="user-img">
<a href="#"><img src="data/profile/avatar-4.png" alt=""></a>
</div>
<div class="user-info">
<h4><a href="#">Carri Busey</a></h4>
<span class="status offline" data-status="offline"> Offline</span>
</div>
<div class="user-status offline">
<i class="fa fa-circle"></i>
</div>
</li>
<li class="user-row" id='chat_user_5' data-user-id='5'>
<div class="user-img">
<a href="#"><img src="data/profile/avatar-5.png" alt=""></a>
</div>
<div class="user-info">
<h4><a href="#">Melissa Dock</a></h4>
<span class="status offline" data-status="offline"> Offline</span>
</div>
<div class="user-status offline">
<i class="fa fa-circle"></i>
</div>
</li>
<li class="user-row" id='chat_user_6' data-user-id='6'>
<div class="user-img">
<a href="#"><img src="data/profile/avatar-1.png" alt=""></a>
</div>
<div class="user-info">
<h4><a href="#">Verdell Rea</a></h4>
<span class="status available" data-status="available"> Available</span>
</div>
<div class="user-status available">
<i class="fa fa-circle"></i>
</div>
</li>
<li class="user-row" id='chat_user_7' data-user-id='7'>
<div class="user-img">
<a href="#"><img src="data/profile/avatar-2.png" alt=""></a>
</div>
<div class="user-info">
<h4><a href="#">Linette Lheureux</a></h4>
<span class="status busy" data-status="busy"> Busy</span>
</div>
<div class="user-status busy">
<i class="fa fa-circle"></i>
</div>
</li>
<li class="user-row" id='chat_user_8' data-user-id='8'>
<div class="user-img">
<a href="#"><img src="data/profile/avatar-3.png" alt=""></a>
</div>
<div class="user-info">
<h4><a href="#">Araceli Boatright</a></h4>
<span class="status away" data-status="away"> Away</span>
</div>
<div class="user-status away">
<i class="fa fa-circle"></i>
</div>
</li>
<li class="user-row" id='chat_user_9' data-user-id='9'>
<div class="user-img">
<a href="#"><img src="data/profile/avatar-4.png" alt=""></a>
</div>
<div class="user-info">
<h4><a href="#">Clay Peskin</a></h4>
<span class="status busy" data-status="busy"> Busy</span>
</div>
<div class="user-status busy">
<i class="fa fa-circle"></i>
</div>
</li>
<li class="user-row" id='chat_user_10' data-user-id='10'>
<div class="user-img">
<a href="#"><img src="data/profile/avatar-5.png" alt=""></a>
</div>
<div class="user-info">
<h4><a href="#">Loni Tindall</a></h4>
<span class="status away" data-status="away"> Away</span>
</div>
<div class="user-status away">
<i class="fa fa-circle"></i>
</div>
</li>
<li class="user-row" id='chat_user_11' data-user-id='11'>
<div class="user-img">
<a href="#"><img src="data/profile/avatar-1.png" alt=""></a>
</div>
<div class="user-info">
<h4><a href="#">Tanisha Kimbro</a></h4>
<span class="status idle" data-status="idle"> Idle</span>
</div>
<div class="user-status idle">
<i class="fa fa-circle"></i>
</div>
</li>
<li class="user-row" id='chat_user_12' data-user-id='12'>
<div class="user-img">
<a href="#"><img src="data/profile/avatar-2.png" alt=""></a>
</div>
<div class="user-info">
<h4><a href="#">Jovita Tisdale</a></h4>
<span class="status idle" data-status="idle"> Idle</span>
</div>
<div class="user-status idle">
<i class="fa fa-circle"></i>
</div>
</li>
</ul>
</div>
</div>
<div class="chatapi-windows ">
</div> </div>
<!-- END CONTAINER -->
<!-- LOAD FILES AT PAGE END FOR FASTER LOADING -->
<!-- CORE JS FRAMEWORK - START -->
<script src="assets/js/jquery-1.11.2.min.js" type="text/javascript"></script>
<script src="assets/js/jquery.easing.min.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="assets/plugins/pace/pace.min.js" type="text/javascript"></script>
<script src="assets/plugins/perfect-scrollbar/perfect-scrollbar.min.js" type="text/javascript"></script>
<script src="assets/plugins/viewport/viewportchecker.js" type="text/javascript"></script>
<!-- CORE JS FRAMEWORK - END -->
<!-- OTHER SCRIPTS INCLUDED ON THIS PAGE - START -->
<script src="assets/plugins/jquery-validation/js/jquery.validate.min.js" type="text/javascript"></script> <script src="assets/plugins/jquery-validation/js/additional-methods.min.js" type="text/javascript"></script> <script src="assets/js/form-validation.js" type="text/javascript"></script> <!-- OTHER SCRIPTS INCLUDED ON THIS PAGE - END -->
<!-- CORE TEMPLATE JS - START -->
<script src="assets/js/scripts.js" type="text/javascript"></script>
<!-- END CORE TEMPLATE JS - END -->
<!-- Sidebar Graph - START -->
<script src="assets/plugins/sparkline-chart/jquery.sparkline.min.js" type="text/javascript"></script>
<script src="assets/js/chart-sparkline.js" type="text/javascript"></script>
<!-- Sidebar Graph - END -->
<!-- General section box modal start -->
<div class="modal" id="section-settings" tabindex="-1" role="dialog" aria-labelledby="ultraModal-Label" aria-hidden="true">
<div class="modal-dialog animated bounceInDown">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Section Settings</h4>
</div>
<div class="modal-body">
Body goes here...
</div>
<div class="modal-footer">
<button data-dismiss="modal" class="btn btn-default" type="button">Close</button>
<button class="btn btn-success" type="button">Save changes</button>
</div>
</div>
</div>
</div>
<!-- modal end -->
</body>
</html>
答案 0 :(得分:1)
如果您需要重复行,请从表中删除索引:
ALTER TABLE `textarea`
DROP INDEX `message`
DROP INDEX `user_id`
DROP INDEX `numb`
DROP PRIMARY KEY;
以上是一个陈述。
另请阅读manual