Hiding "write reply" textfield under each comment - php

I'm working on my school project which is gallery, a clone of flickr and unsplash really.
Right now I was working on comments system which works rather well all things considered, but I also want to add replies under those comments and having textfields under each comment seems clunky, so I wrote small jQuery script for it:
This is test file for this part of the code, as I don't want to ruin something in the main project if something happens.
PHP/HTML
<?php
require_once 'header.php';
if(isset($_POST['submit-comment']))
{
require_once 'includes/dbh.inc.php';
$userUid = "Bob";
$comment = $_POST['comment-input'];
$pageId = 24;
$parentId= -1;
$date = date("Y-m-d H:m:s");
$sql = "INSERT INTO comments(commentsPageId, commentsParentsId, commentsUseruid, commentsContent, commentsDate) VALUES (?,?,?,?,?);";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql))
{
echo "OPPSIE!";
}
else
{
mysqli_stmt_bind_param($stmt, "iissi", $pageId, $parentId, $userUid, $comment, $date);
mysqli_stmt_execute($stmt);
}
mysqli_stmt_close($stmt);
}
$sqlSec = "SELECT commentsId, commentsUseruid, commentsContent, commentsDate FROM comments WHERE commentsPageId=24;";
$stmtSec = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmtSec, $sqlSec))
{
echo "OPPSIE!";
}
else
{
mysqli_stmt_execute($stmtSec);
$result = mysqli_stmt_get_result($stmtSec);
echo '
<div class="comments_container">
<div class="comment-post">
<form action="" method="post">
<textarea name="comment-input" cols="100" rows="4" style="resize: none;" placeholder="Write your comment..."></textarea>
<button type="submit" name="submit-comment">Post comment</button>
</form>
</div>
<div class="comments">
';
while($row = mysqli_fetch_assoc($result))
{
$commentId = $row["commentsId"];
echo '
<div class="comment_'.$commentId.'"?
<div class="header">
<p class="name" style="color: black;">'.$row["commentsUseruid"].'</p>
<span class="date">'.$row["commentsDate"].'</span>
</div>
<p class="content" style="color: black;">'.$row["commentsContent"].'</p>
<div class="reply_'.$commentId.'">
<form action="" method="post">
<textarea id="reply" name="comment-input" cols="80" rows="2" style="resize: none;" placeholder="Write your comment..."></textarea>
<button type="submit" name="submit-comment">Post comment</button>
</form>
</div>
<button class="replybtn_'.$commentId.'">Reply</button>
';
}
echo '</div>';
echo '</div>';
}
?>
jQuery
var id= '<?php echo $commentId; ?>';
var reply = ".reply_";
var selectorReply = reply.concat(id);
var replybtn = ".replybtn_";
var selectorBtn = replybtn.concat(id);
$(selectorBtn).click(function(){
$(selectorReply).toggle()
});
This kinda works, but while($row = mysqli_fetch_assoc($result)), just spins through all id's and stops at the last one, so all reply buttons only work on the last comment.
Question is how do I apply this script to all comments, instead of only the last so that reply buttons show textfields that are appropriate?

Instead of writing jquery code for all button individually you can write your event handler like this $("button[class*=replybtn_]").click(function() { so this event will get called when any button has class i.e :replybtn and anything after that word. As you have use _ to attach id as well you can use split("_")[1] this will give you value after _ then using this you can toggle your reply div.
Demo Code:
$("button[class*=replybtn_]").click(function() {
console.log($(this).attr("class").split("_")[1])
var ids = $(this).attr("class").split("_")[1];
$(".reply_" + ids).toggle()
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="comments_container">
<div class="comments">
<div class="comment_123">
<div class="header">
<p class="name" style="color: black;">123</p>
<span class="date">12/10/2002</span>
</div>
<p class="content" style="color: black;">All Goood..</p>
<div class="reply_123">
<form action="" method="post">
<textarea id="reply" name="comment-input" cols="80" rows="2" style="resize: none;" placeholder="Write your comment..."></textarea>
<button type="submit" name="submit-comment">Post comment</button>
</form>
</div>
<button class="replybtn_123">Reply</button>
</div>
----------------------------------------------
<div class="comment_231">
<div class="header">
<p class="name" style="color: black;">231</p>
<span class="date">12/10/2001</span>
</div>
<p class="content" style="color: black;">All Goood or not..</p>
<div class="reply_231">
<form action="" method="post">
<textarea id="reply" name="comment-input" cols="80" rows="2" style="resize: none;" placeholder="Write your comment..."></textarea>
<button type="submit" name="submit-comment">Post comment</button>
</form>
</div>
<button class="replybtn_231">Reply</button>
</div>
---------------------------------------
<div class="comment_456">
<div class="header">
<p class="name" style="color: black;">456</p>
<span class="date">12/10/1992</span>
</div>
<p class="content" style="color: black;">All Aweomese Goood..</p>
<div class="reply_456">
<form action="" method="post">
<textarea id="reply" name="comment-input" cols="80" rows="2" style="resize: none;" placeholder="Write your comment..."></textarea>
<button type="submit" name="submit-comment">Post comment</button>
</form>
</div>
<button class="replybtn_456">Reply</button>
</div>
</div>

Related

Inserting data into database error: Call to a member function query() on null

I am having difficulty inserting into a database from the following html and php
Here is the html:
<body>
<form action="insert.php" method="post">
<div id="sgc">
<div id="logo">
Student Grade Checker App
</div>
<div>
<textarea class="display-input" id="input-text" rows="5" cols="35" name="input_text" placeholder="Enter the module names and marks separated by comma [put each mod>
</div>
<div>
<textarea class="display-output" id="output-text" rows="5" cols="35" readonly=1 placeholder="Results here..." value="">
</textarea>
</div>
<div>
<button class="sgcbutton-active" name="total_marks" onclick="verify();getTotal();">Total Marks</button>
</div>
<div>
<button class="sgcbutton-active" onclick="verify();getMaxMin();">Highest & Lowest Scoring Modules</button>
</div>
<div>
<button class="sgcbutton-active" onclick="verify();getSortedModules();">Sort Modules</button>
</div>
<div>
<button class="sgcbutton-active" onclick="verify();getClassification();">Classify Grade</button>
</div>
<div>
<button class="sgcbutton-active" onclick="verify();getAverage();">Overall Average</button>
</div>
<div>
<button class="sgcbutton-active" onclick="verify();getIndividualClassification();">Individual Module Classification</button>
</div>
<div>
<button class="sgcbutton-clear" onclick="clearText();">Clear</button>
</div>
</div>
</form>
</body>
The php code:
<?php
if (isset($_POST['total_marks'])){
$totalMarks = $_POST['total_marks'];}
$insertsql = "INSERT INTO total_marks (Module) VALUES('$totalMarks')";
$result = $conn->query($insertsql);
if (!$result) {
echo $conn->error;
}
?>
I am only working with the first button to get it working i will want to eventually insert the others too.
I am getting this error:
Fatal error: Uncaught Error: Call to a member function query() on null in /var/www/html/insert.php:9 Stack trace: #0 {main} thrown in /var/www/html/insert.php on line 9
My database connection is successful.
Any help is always appricated.
if I'm not mistake add to button type="submit"
<button type="submit" class="sgcbutton-active" name="total_marks" onclick="verify();getTotal();">Total Marks</button>
What you want to do now requires a button with the name total_marks and type submit all the code should look like this
<?php
if (isset($_POST['total_marks'])){
$totalMarks = $_POST['total_marks'];}
$insertsql = "INSERT INTO total_marks (Module) VALUES('$totalMarks')";
$result = $conn->query($insertsql);
if (!$result) {
echo $conn->error;
}
?>
<body>
<form action="insert.php" method="post">
<div id="sgc">
<div id="logo">
Student Grade Checker App
</div>
<div>
<textarea class="display-input" id="input-text" rows="5" cols="35" name="input_text" placeholder="Enter the module names and marks separated by comma [put each mod>
</div>
<div>
<textarea class="display-output" id="output-text" rows="5" cols="35" readonly=1 placeholder="Results here..." value="">
</textarea>
</div>
<div>
<button class="sgcbutton-active" name="total_marks" onclick="verify();getTotal();">Total Marks</button>
</div>
<div>
<button class="sgcbutton-active" onclick="verify();getMaxMin();">Highest & Lowest Scoring Modules</button>
</div>
<div>
<button class="sgcbutton-active" onclick="verify();getSortedModules();">Sort Modules</button>
</div>
<div>
<button class="sgcbutton-active" onclick="verify();getClassification();">Classify Grade</button>
</div>
<div>
<button class="sgcbutton-active" onclick="verify();getAverage();">Overall Average</button>
</div>
<div>
<button class="sgcbutton-active" onclick="verify();getIndividualClassification();">Individual Module Classification</button>
</div>
<div>
<button class="sgcbutton-clear" type="submit" name="total_marks" onclick="clearText();">Clear</button>
</div>
</div>
</form>
</body>

Deleting aMySQL database with a button in PHP HTML

I wanted to delete a row in mysql phpmyadmin database through a button in AssetApprovalForm.php, but when I clicked on the decline button in AssetApprovalForm.php nothing happens.
This is the image for AssetApprovalForm.php
This is my code in AssetApprovalForm.php
<form action='delete.php?SN="<?php echo $SerialNumber; ?>"' method="post">
<div class="row">
<div class="col-sm-6">
<div class="inputfield">
<input type="text" id="decline" name="decline" value="Decline" class="btn" >
</div>
</div>
</form>
<div class="col-sm-6">
<div class="inputfield">
<input type="text" id="submit" name="accept" value="Approve" class="btn">
</div>
</div>
</div>
I have included JavaScript in my AssetApprovalForm.php to perform a pop up after the button is clicked.
<script>
$("#decline").click(function(){
swal("Bruh!", "This ticket has been declined", "error");
});
</script>
<script>
$("#submit").click(function(){
swal("Nice!", "This ticket has been approved", "success");
});
</script>
This is my code for delete.php
<?php
include 'db_connection.php';
$SerialNumber = $_GET["serial"];
$query = "DELETE * FROM waiting_approval WHERE SerialNumber = '" . $SerialNumber . "'";
if(mysqli_query($conn, $query))
{
mysqli_close($conn);
header('Location: AssetApprovalList.php');
exit;
}
else
{
echo "Error declining request";
}
?>
Current:-
<div class="col-sm-6">
<div class="inputfield">
<input type="decline" id="decline" name="decline" value="Decline" class="btn">
</div>
</div>
<div class="col-sm-6">
<div class="inputfield">
<input type="text" id="submit" name="accept" value="Approve" class="btn">
</div>
</div>
I think your input type is wrong it should be type="text" not type="decline"
and for submit button it should be type="submit" not type="text"

How to fix 'If(isset($_POST['Id'])) error' while editing the form in a PHP based CRUD application?

The "if(isset($_POST["titleId"]) && !empty($_POST["titleId"])" in my code is returning false value.
I'm working on a CRUD application, the insert modal is working fine, now I'm stuck at the update part of it. So when you click on the update icon it does fetch the right titleId in the URL but the first 'if' condition returns false and hence the update isn't working.
Here's what I've tried so far.
admin.php
<?php
$typeId = filter_input(INPUT_GET, "type");
$titleId = filter_input(INPUT_GET, "titleId");
$active = "admin" . $typeId;
require_once './pages/header.php';
require_once './functions/queries.php';
$getAll = Queries::getAllTitle($typeId);
?>
<div class="container">
<div class="wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="page-header clearfix">
<h2 class="pull-left"></h2>
<button type="button" class="btn btn-success btn-sm" data-toggle="modal" data-target="#facultyAddModal">Add Title</button>
</div>
<!--<div class="container">
<button type="button" class="btn btn-success btn-sm" data-toggle="modal" data-target="#facultyAddModal">Add Title</button>
<br><br>-->
<div class="panel-group" id="titleAccordion">
<?php
for ($i = 0; $i < count($getAll); $i++) {
echo <<<HTML
<div class="panel panel-default">
<div class="panel-heading"><h4 class="panel-title">
<a data-toggle="collapse" data-parent="#titleAccordion" href="#collapseF{$i}">{$getAll[$i]['title']}</a></h4>
</div>
<div id="collapseF{$i}" class="panel-collapse collapse" >
<div class="panel-body">
<div class="table-responsive">
<table class="table table-condensed"><tbody>
<tr><td>Title:</td><td>{$getAll[$i]['title']}</td></tr>
<tr><td>Units:</td><td>{$getAll[$i]['units']}</td></tr>
<tr><td>Category:</td><td>{$getAll[$i]['category']}</td></tr>
<tr><td>
<tr><td><input type="hidden" id="titleId" name="titleId" value="{$getAll[$i]['titleId']}"> </tr><td>
<a href='edit.php?titleId={$getAll[$i]['titleId']}' title='Update Record' data-toggle='tooltip'><span class='glyphicon glyphicon-pencil'></span></a>
<a href='delete.php?titleId={$getAll[$i]['titleId']}' title='Delete Record' data-toggle='tooltip'><span class='glyphicon glyphicon-trash'></span></a>
</tr></td>
</tbody></table>
</div>
</div>
</div>
</div>
HTML;
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Title Add Modal-->
<div class="modal fade" id="facultyAddModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Add Title</h4>
</div>
<div class="modal-body">
<div id="adminResult" class="hide" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<div id="resultAdminContent"></div>
</div>
<form class="cmxform" id="adminForm" method="post">
<label for="Activity">ActivityAttended (required)</label>
<input class="form-control" id="adminTitle" name="title" type="text" required>
<br>
<label for="units">Units (required)</label>
<input class="form-control" id="adminUnits" type="number" name="units" required>
<br>
<label for="Category">Category (Optional)</label>
<input class="form-control" id="adminCategory" type="text" name="category">
<br>
<?php echo
'<input type="hidden" id="addadminTypeId" value="'.$typeId.'">';
?>
<?php echo
'<input type="hidden" id="titleId" name="titleId" value="'.$titleId.'">';
?>
<button class="btn btn-info btn-primary" type="submit">Submit</button>
<br>
<br>
</form>
</div>
</div>
</div>
</div>
update.php
<?php
require_once 'functions/db_connection.php';
$conn = DB::databaseConnection();
$title = $units = $category = "";
if(isset($_POST["titleId"]) && !empty($_POST["titleId"])){
$titleId = $_POST['titleId'];
$sql = "UPDATE title SET title = :title, units = :units, category = :category WHERE titleId = :titleId";
if($stmt = $conn->prepare($sql))
{
// Bind variables to the prepared statement as parameters
$stmt->bindParam(':titleId', $titleId);
$stmt->bindParam(':title', $title);
$stmt->bindParam(':units', $units);
$stmt->bindParam(':category', $category);
if ($stmt->execute()) {
header("location: index.php");
exit();
} else{
echo "Something went wrong. Please try again later.";
}
unset($stmt);
}
unset($conn);
} else{
if(isset($_GET["titleId"]) && !empty(trim($_GET["titleId"]))){
$titleId = trim($_GET["titleId"]);
$sql = "SELECT * FROM title WHERE titleId = :titleId";
if($stmt = $conn->prepare($sql))
{
$stmt->bindParam(':titleId', $titleId);
if ($stmt->execute()){
if($stmt->rowCount() == 1){
$result = $stmt->fetch(PDO::FETCH_ASSOC);
// Retrieve individual field value
$title = $result["title"];
$units = $result["units"];
$category = $result["category"];
} else{
echo"error1";
exit();
}
} else{
echo "Oops! Something went wrong. Please try again later.";
}
}
unset($stmt);
unset($conn);
} else{
// URL doesn't contain id parameter. Redirect to error page
echo"error2";
exit();
}
}
?>
<!--<!DOCTYPE html>-->
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Update Record</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
<style type="text/css">
.wrapper{
width: 500px;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="page-header">
<h2>Update Record</h2>
</div>
<form action="<?php echo htmlspecialchars(basename($_SERVER['REQUEST_URI'])); ?>" method="post">
<label for="Activity">Title</label>
<input class="form-control" id="adminTitle" name="title" type="text" value="<?php echo $title; ?>" required>
<br>
<label for="units">Units (required)</label>
<input class="form-control" id="adminUnits" type="number" name="units" value="<?php echo $units; ?>" required>
<br>
<label for="Category">Category (Optional)</label>
<input class="form-control" id="adminCategory" type="text" value="<?php echo $category; ?>" name="category">
<br>
<input type="hidden" name="titleId" value="<?php echo $titleId; ?>">
<button class="btn btn-info btn-primary" type="submit">Submit</button>
<br>
<br>
</form>
</div>
</<div>
</div>
</div>
</div>
</body>
</html>
The only goal here is to get the update form working, the user should be able to update the records of the respective title being selected.
I don't know crud but I think there is a way to debug a little:
e.g. try this:
if(isset($_POST["titleId"]) && !empty($_POST["titleId"])){
// test if you are here:
echo 'hi, yeah I am here!';
}
or this
echo '<pre>';
var_dump($_POST);
echo '</pre>';
// before:
if(isset($_POST["titleId"]) && !empty($_POST["titleId"])){
// ...
}
also, take a look at
error_get_last()['message']

php echo file get content on textarea when press button

Hello i have code like this
<html>
<div class="col-xs-3">
<div class="form-group">
<button type="button" id="get_sock" name="get_sock" class="btn-info">Get Socks5</button>
<div>
<textarea name="socks" id="socks" class="form-control" rows="7" placeholder="127.0.0.1:8080"><?php
if (isset($_POST['get_sock'])) {
$grab = file_get_contents("http://smansara.net/fake/grab.php");
echo $grab;
}
?></textarea>
</div>
</div>
</div>
</html>
but i have a problem when i click the button, nothing happens when i click the button, please review my code sir
Add Form tag Before button then it works correctly
<html>
<div class="col-xs-3">
<div class="form-group">
<form action="" method="POST">
<input type="submit" id="get_sock" name="get_sock" class="btn-info" value="get_sock">
</form>
<div>
<textarea name="socks" id="socks" class="form-control" rows="7" placeholder="127.0.0.1:8080">
<?php
if (isset($_POST['get_sock'])) {
$grab = file_get_contents("http://smansara.net/fake/grab.php");
print_r($grab);
}
?></textarea>
</div>
</div>
</div>
</html>
You need to create an Ajax function on this button click then also need to create an php file which will simply read file content and echo them.
So when you Ajax will called on button click then in response you will get file content the you can add that response to your text area in success.
If you don't know about Ajax then search on internet ,.,here i have given an demo example
$(".yourbuttonclass").click(function(){
$.ajax({url: "phpfilename.php", success: function(result){
$("#textarea_id").html(result);
}});
});
You should probably wrap your input inside a form and then change button into submit type in order to make the $_POST['get_sock'] available for your if statement. For Example (Somehow can't make the </form> tag appears at the end or my snippet)
<html>
<form method="post">
<div class="col-xs-3">
<div class="form-group">
<input type="submit" id="get_sock" name="get_sock" class="btn-info" value="Get Sock">
<div>
<textarea name="socks" id="socks" class="form-control" rows="7" placeholder="127.0.0.1:8080"><?php
if (isset($_post['get_sock'])) {
$grab = file_get_contents("http://smansara.net/fake/grab.php");
echo $grab;
}
?></textarea>
</div>
</div>
</div>
$_post is not correct. Use $_POST
<html>
<div class="col-xs-3">
<div class="form-group">
<button type="button" id="get_sock" name="get_sock" class="btn-info">Get Socks5</button>
<div>
<textarea name="socks" id="socks" class="form-control" rows="7" placeholder="127.0.0.1:8080">
<?php if(isset($_POST['get_sock'])){
$grab = file_get_contents("http://smansara.net/fake/grab.php");
echo $grab;
} ?>
</textarea>
</div>
</div>
</div>
You can use input type='button' so that form won't submit if you have.Form is not necessary for ajax call.Try like this:
<html>
<div class="col-xs-3">
<div class="form-group">
<input type="button" id="get_sock" name="get_sock" class="btn-info" value='Get Socks5'>
<div>
<textarea name="socks" id="socks" class="form-control" rows="7" placeholder="127.0.0.1:8080"></textarea>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(function(){
$('#get_sock').on('click',function(){
var contents='<?=nl2br(file_get_contents("http://smansara.net/fake/grab.php"))?>';
var content = contents.split('</br>').join('\n');
$('#socks').html(content);
});
//ajax
$.ajax({
type:'POST',
url :'filename.php',//returns the file_get_contents
success:function(data){
$('#socks').html(data);
}
});
});
</script>
</html>
<html>
<div class="col-xs-3">
<div class="form-group">
<form action="" method="POST">
<input type="submit" id="get_sock" name="get_sock" class="btn-info" value="get_sock">
</form>
<div>
<?php
$tareas='<textarea name="socks" id="socks" class="form-control" rows="7" placeholder="127.0.0.1:8080">';
$tareae='</textarea>';
(isset($_POST['get_sock']))?$grab=file_get_contents("http://smansara.net/fake/grab.php"):$grab='';
echo $tareas,$grab,$tareae;?>
</div>
</div>
</div>
</html>

Mysql query succeeds but doesnt reflect in the database

Please guys my code isn't working and i don't know what to do anymore. All i'm trying to accomplish is a simple mysql update using php. The header query value works at the top of my code which i use to insert values in the form, but when i attempt to submit, for some reason unknown to me, my script succeeds but it doesn't update the database. The result of clicking the submit will be my "Javascript success alert" then " all the variables in my page become Undefined. My script is below.
<?php
//Catch the id from the header and query database
if(isset($_GET['id']))
$workID= mysqli_real_escape_string($connection, $_GET['id']);
$query = "SELECT * FROM music WHERE musicID = $workID";
$result= mysqli_query($connection, $query);
$row = mysqli_fetch_array($result);
$artID = $row['IDartiste'];
$query2 = mysqli_query($connection,"SELECT music.*, artiste.* FROM music INNER JOIN artiste ON music.IDartiste=artiste.artisteID WHERE artiste.artisteID = $artID");
$row2 = mysqli_fetch_array($query2);
?>
**This is the form for editing**
<form role="form" method="get" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<!-- Artiste name field--> <div class="form-group">
<span><label for="topic" style="color: #55AAFF">Artiste ID: </span> <span><?php echo $row['IDartiste'];?></span></label>
<!-- Article topic field--> <div class="form-group">
<label for="topic" style="color: #55AAFF">Music title:</label>
<input type="text" class="form-control" name="title" value="<?php echo $row['musicTitle'];?>" autofocus>
</div>
<!--Article textarea--> <div class="form-group">
<label for="body" style="color: #55AAFF">Content (text):</label>
<textarea name="article" class="form-control"><?php echo $row['musicArticle'];?>
</textarea>
</div>
<!-- Upload image start--> <div class="col-ms-6 col-xs-12" >
<div class="panel panel-default">
<div class="panel-heading" style="color: #55AAFF">Upload Image</div>
<div class="panel-body">
<iframe src="fileupload.php" width="100%" style="border:none"></iframe>
</div>
</div>
</div>
<!--Image link field--> <div class="form-group">
<label for="image_link" style="color: #55AAFF">Input image link: </label>
<input type="text" name="image" value="<?php echo $row['musicPhoto'];?>" class="form-control"/>
</div>
<!-- Upload music start--> <div class="col-ms-6 col-xs-12" >
<div class="panel panel-default">
<div class="panel-heading" style="color: #55AAFF">Upload Music</div>
<div class="panel-body">
<iframe src="music_file_upload.php" width="100%" style="border:none"></iframe>
</div>
</div>
</div>
<!--Music link field--> <div class="form-group">
<label for="music_link" style="color: #55AAFF">Input music link: </label>
<input type="text" name="file" class="form-control" value="<?php echo $row['musicFile'];?>"/>
</div>
<center>....<button type="submit" class="btn btn-default" id="btnsubmit" name="btnsubmit" style="color: #55AAFF">Update</button>....</center>
<br />
</form>
This is the update script
<?php
if(isset($_GET['btnsubmit'])){
date_default_timezone_set('Africa/Lagos');
$setdate= date('Y-m-d-h-m-s');
$date= strftime($setdate);
$time= strftime('%X');
$title = $_GET["title"];
$article = $_GET["article"];
$artisteImage = $_GET["image"];
$musicFile = $_GET["file"];
$sql_music = "UPDATE kingdomjoy.music SET musicTitle = '$title',
musicFile = '$musicFile',
musicPhoto = '$artisteImage',
musicArticle = '$article',
entryDate = '$date'
WHERE musicID = '$workID' LIMIT 1";
$musicupdate = $connection->query($sql_music);
if ($musicupdate === FALSE) {
echo "Error: " . die(mysqli_error($connection));}
else {echo"<script>swal('Success! music library updated')</script>";}
}
?>

Categories