?> </strong> <p> <?php $description = $idea['Idea']['description']; echo $description; ?> </p> <?php if (!isIdeaOfUser($_SESSION['email'], $_GET['id']) && isset($_SESSION['email'])) { ?> <div id="listFollow"> <?php $hasAlreadyFollower = hasAlreadyFollower($_SESSION['email'], $_GET['id']); if (!$hasAlreadyFollower) { echo "<button type='button' onClick='followIt();' id='followIt' class='btn btn-default btn-lg' style='background: green'><span class='glyphicon glyphicon-ok' aria-hidden='true'></span> Follow</button>"; } else { echo "<button type='button' onClick='notFollowIt();' id='notFollowIt' class='btn btn-default btn-lg' style='background: red'><span class='glyphicon glyphicon-remove' aria-hidden='true' ></span> Unfollow</button>"; } ?> </div> <?php } ?>
/** * @author Amedeo Leo */ function insertFollower($idUser, $idIdea) { if (isIdeaOfUser($idUser, $idIdea)) { return NULL; } if (hasAlreadyFollower($idUser, $idIdea)) { return NULL; } $date = getTimeAndDate(); $conn = getConn(); $sql = "INSERT INTO follow (idUser, idIdea, date) VALUES ('{$idUser}','{$idIdea}','{$date}')"; $result = mysqli_query($conn, $sql) or die("Insert failed"); mysqli_close($conn); return $result; }