iProZy 0 Denunciar post Postado Agosto 6, 2015 Sou mt novato em php, então queria uma ajuda de vcs, eu aprendi básico do básico então unica coisa que não consegui fazer no meu painel Dj foi a parte de "Dj Online". Então estou criando um painel de Dj para minha web rádio, estou querendo fazer um botão de Entrar no ar que mudaria na bd "status" de off para "on", exemplo ////////////////////////////////////////////////////////////////////////////////////////// // locutor: // status // Botoes // ////////////////////////////////////////////////////////////////////////////////////////// // MeuNomeDj // Off // Entrar Online (botão)// ////////////////////////////////////////////////////////////////////////////////////////// após clicar no botão "Entrar Online" que mudaria o "status" no banco de dados de "Off" para "On" o botão mudaria de "Entrar Online" para "Ficar Offline". Botão "Ficar Offline" mudaria o status de "On" para "Off", exemplo: ////////////////////////////////////////////////////////////////////////////////////////// // locutor: // status // Botoes // ////////////////////////////////////////////////////////////////////////////////////////// // MeuNomeDj // On // Ficar Offline (botão) // ////////////////////////////////////////////////////////////////////////////////////////// OBS: aparecer essa tabela só com os dados do Dj que está online no painel. OBS²: E se der, quando um Dj estiver Online o outro não pode ficar tbm ... a parecer uma msg avisando que já tem um online (exemplo: o Dj MeuNomeDj já está Online no momento! ), ou algo do tipo, para evitar bugs de aparecer dois Dj's Online no site. OBS³: Se tiver botão de "Forçar todos os Dj's a ficar Offline" botão de emergência para quando algum Dj ficar sem net e n conseguir deixar Offline rs. Bom, tentei explicar ao máximo rs, só de ter os botões para ficar On e Off já está bom, o resto eu sei que é pedir demais rs, pena que sou novato nisso e ainda não sei fazer coisas desse tipo :( Se alguém poder ajudar, ficarei grato ^^ Compartilhar este post Link para o post Compartilhar em outros sites
Alaerte Gabriel 662 Denunciar post Postado Agosto 6, 2015 Mostre o que tentou fazer. Estamos aqui para auxiliar. Compartilhar este post Link para o post Compartilhar em outros sites
iProZy 0 Denunciar post Postado Agosto 7, 2015 Mostre o que tentou fazer. Estamos aqui para auxiliar. bom, eu criei um botão levando para um pagina que muda o status de Off para On porem essa pagina "atualizar.php" só funciona se eu por a ID do usuário, então eu tenho que ficar criando várias paginas com IDs diferentes para mudar. Quando eu voltar para casa eu irei copiar e mostrar como eu fiz Compartilhar este post Link para o post Compartilhar em outros sites
Alaerte Gabriel 662 Denunciar post Postado Agosto 7, 2015 Não precisa copiar várias páginas. Procure sobre QUERY STRING. Só é preciso uma página para puxar os dados com o link para enviar para a segunda que irá recuperar. Ou na mesma página, caso queira. Compartilhar este post Link para o post Compartilhar em outros sites
iProZy 0 Denunciar post Postado Agosto 7, 2015 Não precisa copiar várias páginas. Procure sobre QUERY STRING. Só é preciso uma página para puxar os dados com o link para enviar para a segunda que irá recuperar. Ou na mesma página, caso queira. consegui resolver com o seguinte código index.php <?php require_once('../Connections/config.php'); ?> <?php //initialize the session if (!isset($_SESSION)) { session_start(); } // ** Logout the current user. ** $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true"; if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){ $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){ //to fully log out a visitor we need to clear the session varialbles $_SESSION['MM_Username'] = NULL; $_SESSION['MM_UserGroup'] = NULL; $_SESSION['PrevUrl'] = NULL; unset($_SESSION['MM_Username']); unset($_SESSION['MM_UserGroup']); unset($_SESSION['PrevUrl']); $logoutGoTo = "../index.php"; if ($logoutGoTo) { header("Location: $logoutGoTo"); exit; } } ?> <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = "admin"; $MM_donotCheckaccess = "false"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && false) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "../painel_dj.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) $MM_referrer .= "?" . $_SERVER['QUERY_STRING']; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_config, $config); $query_users = "SELECT * FROM users"; $users = mysql_query($query_users, $config) or die(mysql_error()); $row_users = mysql_fetch_assoc($users); $totalRows_users = mysql_num_rows($users); ?> <div id="cont-nome">Ao Vivo</div><!-- fim cont-nome --> <div id="contas" style="width:867px"> <div id="contas-nome">Usuario</div> <div id="contas-nome">Locutor</div> <div id="contas-nome">Status</div> <div id="contas-btn" style="width:200px">Opções</div> <!-- repetir --> <?php do { ?> <div id="contas-nome"><?php echo $row_users['usuario']; ?></div> <div id="contas-nome"><?php echo $row_users['locutor']; ?></div> <div id="contas-nome"><?php echo $row_users['status']; ?></div> <div id="contas-btn" style="width:200px"> <a href="javascript:;" onclick="abrirPag('_pags/update.php?id=<?php echo $row_users['id']; ?>')">Entrar no Ar</a> <a href="_pags/contas_del.php?id=<?php echo $row_users['id']; ?>">Ficar Off</a> </div> <?php } while ($row_users = mysql_fetch_assoc($users)); ?> <!-- fim repetir --> <div style="clear:both"></div> <?php mysql_free_result($users); ?> update.php <?php require_once('../Connections/config.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $colname_users = "-1"; if (isset($_GET['id'])) { $colname_users = $_GET['id']; } mysql_select_db($database_config, $config); $query_users = sprintf("SELECT * FROM users WHERE id = %s", GetSQLValueString($colname_users, "int")); $users = mysql_query($query_users, $config) or die(mysql_error()); $row_users = mysql_fetch_assoc($users); $totalRows_users = mysql_num_rows($users); $conexao = mysql_connect('localhost','root','1230'); $db = mysql_select_db('web_radio'); $id = $row_users['id']; $sql = "UPDATE users SET status = 'on' WHERE id = '$id'"; $rsON = mysql_query($sql); header('location: aovivo.php'); mysql_free_result($users); ?> eu agora só queria uma forma de aparecer uma msg se algum dj já estiver on, assim outro dj não poderia ficar on, isso evitaria de aparecer 2 DJs on no meu site Compartilhar este post Link para o post Compartilhar em outros sites
Alaerte Gabriel 662 Denunciar post Postado Agosto 7, 2015 É só fazer a busca no campo responsável por definir se o DJ está on ou não, faça a busca, se retornar true então já está ON. Compartilhar este post Link para o post Compartilhar em outros sites