Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Egglestron committed May 5, 2018
2 parents dd30fca + 940a49b commit ef11322
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
16 changes: 8 additions & 8 deletions messages.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
//html5andcss3.org
function showEdit(text){
function showEdit(){
var edit = document.getElementById("edit");
var submit = document.getElementById("submit");
var cancel = document.getElementById("cancel");
var name = document.getElementById("nameChat");
var input = document.getElementById("name2");

edit.style.display = "none";
cancel.style.display = "block";
submit.style.display = "block";
name.style.color = "#000000";
name.style.backgroundColor = "#ffffff";
name.contentEditable = "true";
name.innerHTML = text;
name.style.display = "none";
name2.style.display = "block";
}

function hideEdit(){
function hideEdit(text){
var edit = document.getElementById("edit");
var submit = document.getElementById("submit");
var cancel = document.getElementById("cancel");
Expand All @@ -24,6 +23,7 @@ function hideEdit(){
cancel.style.display = "none";
submit.style.display = "none";
name.style.color = "#ffffff";
name.style.backgroundColor = "#4067FF";
name.contentEditable = "false";
name.style.display = "block";
name2.style.display = "none";
name.innerHTML = text;
}
8 changes: 4 additions & 4 deletions messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@
mysqli_stmt_store_result($req);
mysqli_stmt_bind_result($req, $col_IDChatter, $col_FirstName, $col_LastName, $col_UrlMedia, $col_Descri);

echo "<div class='holder' ><form method='post'>";
echo "<div class='holder' ><form class='form-inline' method='post'>";
echo "<h3 style='color:white; font-weight:700; font-size:2em; border-radius:15px' id='nameChat' name='nameChat' contenteditable='false'>$Name</h3>";
echo "<input type='hidden' name='idDiscussion' value='$idDiscussion' id='iddiscussion'> ";
echo "<input class='form-control multitext mr-sm-2' style='display:none; color:black: background-color:white' name='name2' id='name2' type='text' placeholder='$Name' aria-label='Write a message'>";
echo "<button class='btn btn-primary' formaction='updateName.php' id='submit' type='submit' name='submit' style='display:none;'>Validate</button>";
echo "</form>";
echo "<button class='btn btn-primary' onclick='hideEdit(blabla)' id='cancel' style='display:none;' >Cancel</button>";
echo "<button class='btn btn-primary' onclick=\"hideEdit('$Name')\" id='cancel' style='display:none;' >Cancel</button>";
echo "<button class='btn btn-primary' id='edit' onclick=\"showEdit()\">Edit Chat name</button>";
echo "</div>";

Expand Down Expand Up @@ -228,7 +228,7 @@
echo "</div>";
echo "</main>";
}
else{
else if(isset($_SESSION['firstname']) && isset($_SESSION['lastname'])){
$firstname = isset($_SESSION['firstname'])?$_SESSION['firstname']:"";
$lastname = isset($_SESSION['lastname'])?$_SESSION['lastname']:"";

Expand Down
16 changes: 16 additions & 0 deletions updateName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

include("config.php");
session_start();

$idDiscussion = $_SESSION["idDiscussion"];
$name = $_POST["name2"];

$req = mysqli_prepare($db, "UPDATE chatgroups SET Name = ? WHERE ID = ?");
mysqli_stmt_bind_param($req, "si", $name, $idDiscussion);
mysqli_stmt_execute($req);
mysqli_stmt_close($req);

header("Location: {$_SERVER['HTTP_REFERER']}");
exit;
?>

0 comments on commit ef11322

Please sign in to comment.