Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("connect.php");
- include("functions.php");
- if(isset($_POST['id'])){
- $end_user=$_SESSION['email'];
- $sql="SELECT * FROM users WHERE email='$end_user'";
- $rs=mysqli_query($con,$sql);
- $row=mysqli_fetch_array($rs);
- $id_user=$row[0];
- $nsql="SELECT id FROM stickies WHERE id_user='$id_user'";
- $nrs=mysqli_query($con,$nsql);
- $nrow=mysqli_fetch_array($nrs);
- //$stick=$nrow[0];
- $id_stick = $_POST['id'];
- $top = trim($_POST['top']);
- $left = trim($_POST['left']);
- $text = trim($_POST['text']);
- if($id_user && $id_stick && $top && $left && $text){
- for($i = 0;$i < count($nrow);$i++){
- $nsql="SELECT id FROM stickies WHERE id_user='$id_user'";
- $nrs=mysqli_query($con,$nsql);
- $nrow=mysqli_fetch_array($nrs);
- if($nrow[$i]==$_POST['id']){
- $query = "UPDATE stickies SET top = '$top', tLeft = '$left', text = '$text' WHERE id = '$id_stick'";
- mysqli_query($con,$query);
- }
- else {
- $query = "INSERT INTO stickies(id,top,tLeft,text,id_user) VALUES('$id_stick','$top','$left','$text','$id_user')";
- mysqli_query($con,$query);
- }
- }
- }
- echo $nrow[0];
- //echo $id_user;
- }
- // if(isset($_POST['text']) && $_POST['delete']){
- // $query = "DELETE FROM 'stickies' WHERE 'text' = '$text'";
- // mysqli_query($con,$query);
- // echo 'for ajax';
- // }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement