This status(active 1 /inactive 0) button makes any individual record active/inactive.
I need to change it so that when clicked it makes the that record active and all others inactive by changing tbladdress_status db variable.
if (isset($_GET['tbladdress_status'])) {
if ($_GET['tbladdress_status']=="ok") {
$statusupdate=$db->prepare("UPDATE tbl_address SET
tbladdress_status=:tbladdress_status
WHERE tbladdress_id={$_GET['tbladdress_id']}
");
$update=$statusupdate->execute(array(
'tbladdress_status' => $_GET['activestatus']
));
if ($update) {
Header("Location:../../front-address-all.php?status=ok");
} else {
Header("Location:../../front-address-all.php?status=no");
}
}
}
<?php
if ($pulladdress['tbladdress_status']==1) { ?>
<a href="nedmin/netting/pdo-process.php?tbladdress_id=<?php echo $pulladdress['tbladdress_id'] ?>&activestatus=0&tbladdress_status=ok"><button class="btn btn-success btn-xs"><?php echo _ACTIVE; ?></button>
<?php } elseif($pulladdress['tbladdress_status']==0) {?>
<a href="nedmin/netting/pdo-process.php?tbladdress_id=<?php echo $pulladdress['tbladdress_id'] ?>&activestatus=1&tbladdress_status=ok"><button class="btn btn-danger btn-xs"><?php echo _PASSIVE; ?></button>
<?php } ?>
Related
<?php
require_once 'config.php';
session_start();
$result = mysqli_query($link, "SELECT * FROM images where allowance=0 order by id desc");
while ($row = mysqli_fetch_array($result)) {
?>
<div id='img_div'>
<p><?php echo $row['image_text']; ?></p>
<img src="images/<?php echo $row['image']; ?>" >
<br><br>
<a role="button" class="btn btn-outline-success app" name="publish" href='admin.php?publish=true'>Publish</a>
<a role="button" class="btn btn-outline-danger app" name="reject" href='admin.php?reject=true'>Reject</a>
</div>
<?php
}
?>
<?php
if (isset($_GET['publish'])) {
$test=$_GET['id'];
$sql1 = "UPDATE images SET allowance='1' where id=$test";
if (mysqli_query($link, $sql1)) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . mysqli_error($link);
}
}
?>
What i am trying to do here is that i am admin.
when users upload a photo, it will have allowance value as '0'.
click here to see my mysql table with allowance value as 0
It wont be shown in timeline.
I will login through admin. So when i click publish, the allowance value is updated as 1 and thus it will be shown in timeline.
the problem here is that when i use this code all of the image gets updated as value 1.
click here to see my mysql table with allowance value as 0
I cannot find a specific WHERE condition for mysql command to update my allowance value..
or does anybody have any code for this concept..
i.e, user uploads photo it will be stored in database and then after admin approves it it will be shown in timeline...
Thanks in advance...
<?php
require_once 'config.php';
session_start();
if (isset($_GET['publish'])) {
$test=$_GET['id'];
$sql1 = "UPDATE images SET allowance='1' where id=$test";
if (mysqli_query($link, $sql1)) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . mysqli_error($link);
}
}
$result = mysqli_query($link, "SELECT * FROM images where allowance=0 order by id desc");
while ($row = mysqli_fetch_array($result)) { ?>
<div id='img_div'>
<p><?php echo $row['image_text']; ?></p>
<img src="images/<?php echo $row['image']; ?>" >
<br><br>
<a role="button" class="btn btn-outline-success app" name="publish" href='admin.php?publish=true&id=<?php echo $row['id']; ?>'>Publish</a>
<a role="button" class="btn btn-outline-danger app" name="reject" href='admin.php?reject=true'>Reject</a>
</div>
<?php } ?>
how to create a button to hide the value of the database.
for example :
<a href="#alatrusak" class="btn pull-right btn-danger btn3d" id="alatrusakshow" value="<?php echo $detail['status'] ?> ">
value status = 1 and 2
if button1 value status = 1 results show
and
if button1 value status = 2 results hidden
Underneath your button you would just check the value of $detail['status']
<?php
if ($detail['status'] == 1) {
// echo results
} else {
// echo no result message
}
?>
get the value from db $status=$detail['status'] ; and check if present and show it . very simple :)
<?php
$status=$detail['status'] ;
if($status==1){
?>
<a href="#alatrusak" class="btn pull-right btn-danger btn3d" id="alatrusakshow" value="<?php echo $status;?> ">
<?php
}
elseif($status==2){
?>
<a href="#alatrusak" class="btn pull-right btn-danger btn3d" id="alatrusakshow" value="<?php echo $status;?> ">
<?php
}
That's it!! For more detail on conditional statement check this
<?php if($detail['status']=='1') { ?>
<!-- Show anything you want to display when status = 1 -->
<a href="#alatrusak" class="btn pull-right btn-danger btn3d" id="alatrusakshow" value="<?php echo $detail['status'] ?>">
<?php } ?>
My session is lost when I go to a specific menu on my webpage.
on login.php the session is created, then I am redirected to menus.php which is the main page for my user. If I go into usuarios.php and then select one of those users I am redirect to ver_usuarios.php and carry some variables on the url using get method.
When I get to ver_usuarios.php and if I refresh the page the session just expires it kickes me out of the webpage and I'm not using session_destroy(); never. You can see my webpage runnin here: http://santateclacentral.org/login.php user=alejo pass= 123 go to usuarios and then to each user and see the issue here is my code:
USUARIOS.PHP
<?php
include("../conexion.php");
require_once('../sesion_usuarios.php');
include("../paginacion/paginator.class.php");
$query_usuarios = mysql_query("select usuarios.nick_usuario, roles.rol, miembros.imagen_miembro, usuarios.estado_usuario, usuarios.id_usuario, miembros.nombre_miembro from usuarios join roles on usuarios.id_rol = roles.id_rol join miembros on miembros.id_usuario = usuarios.id_usuario $pages->limit");
$hay = mysql_num_rows($query_usuarios);
if($hay){
while ($datos = mysql_fetch_row($query_usuarios)) {
# code...
?>
<td class="resize"><img src="<?php echo $datos[2]?>" width="50px" height="50px"></td>
<td class="resize"><?php echo $datos[5]?></td>
<td class="resize"><?php echo $datos[0]?></td>
<td><?php echo $datos[1]?></td>
//Take a look at this , here is where i get the variables and redirect to ver_usaurios.php page
<td><a class="btn btn-info" href="ver_usuarios.php?user=<?php echo $datos[2]?>&state=<?php echo $datos[3]?>&e=<?php echo $datos[4]?>">Ver</a></td>
<?php
if ($datos[3] == true) {
# code...
?>
<td><a class="btn btn-success" href="activar_usuarios.php?user=<?php echo $datos[2]?>&state=<?php echo $datos[3]?>&k=<?php echo $datos[4]?>&activate=9468752130_edit" value="Ver"> Activar </a></td>
<?php
} else{
?>
<td><a class="btn " href="desactivar_usuarios.php?user=<?php echo $datos[2]?>&state=<?php echo $datos[3]?>&k=<?php echo $datos[4]?>&deactivate=1679854320_edit">Desactivar</a></td>
<?php
}
?>
<!-- <td><a class="btn btn-danger" onClick="borrar(<?php echo $datos[4]?>)">Borrar</a></td> -->
<tr></tr>
<?php
}
}else{
?>
<tr>No hay registros</tr>
<?php
}
?>
VER_USUARIOS.PHP?user=&e=
<?php
require("../conexion.php");
session_start();
require_once('../sesion_usuarios.php');
$query_menus_usuarios = mysql_query("SELECT m.id_menu, m.menu_url, m.nombre_menu FROM menus m join menus_usuarios mu on m.id_menu = mu.id_menu join usuarios u on mu.id_usuario = u.id_usuario where u.id_usuario = '".$_SESSION['id_usuario']."' and mu.estado = 1");
while($menus_mostrar = mysql_fetch_row($query_menus_usuarios)){
if($menus_mostrar[2] == "Usuarios"){
?>
<li class="active"><?php echo $menus_mostrar[2]; ?></li>
<?php
} else {
?>
<li ><?php echo $menus_mostrar[2]; ?></li>
<?php
}
}
?>
<li class="dropdown">
Administrador<b class="caret"></b>
<ul class="dropdown-menu">
<?php
if (!isset($_SESSION['login'])) {
# code...
?>
<li>Login</li>
<?php
} else {
?>
<li class="">Administrar</li>
<li>Cerrar Sesion</li>
<?php
}
?>
It sounds like you forgot to put session_start() at the top of the (each) admin page.
I am surprised to see my top login bar cannot show any change after user login.
Other element of in this bar like logo, decorative div show as it but after 'login to change username' & 'registration to change logout' & 'all notification' display like I am not logged in.
I cannot understand where is my wrong. It cannot show any error also.
Please see my code:
Included my every pages:
<?php include_once("top_login.php"); ?>
my top_login.php
<?php include_once("login/session.php"); ?>
<div id="toplogin">
<div class="logintext1">
<?
if($session->logged_in){
echo '<a class="logintext" href=../login/myprocess.php>Logout</a>';
} else {
echo '<a class="logintext" href="../login/regis.php">Register</a>';
}
?>
</div>
<div class="logintext2">
<?
if($session->logged_in){
echo '<a class="logintext" href="../login/mn.php">'.$_SESSION["username"].'</a>';
} else {
echo '<a class="logintext" href="../login/mn.php">Log In</a>';
}
?>
</div>
<div class="logintext3">
<?
if($session->logged_in){
echo '<a class="logintext" href="#"><img style="padding:2px 2px" src="http://www.mywebsite.com/images/nof2.png" /></a>';
} else {
echo '<a class="logintext" href="../login/mn.php"><img style="padding:2px 2px" src="http://www.mywebsite.com/images/nof.png" /> </a>';
}
?>
</div>
</div>
i am trying to change the login button on my page to a logout button when someone is logged in.
$logged_in = $this->session->userdata('logged_in');
if ($logged_in) {
$data['Lbutton'] = '<div id="login">
<button class="login3"><?php echo anchor("pages/logout", "Logout"); ?></button>
</div>';
} else {
$data['Lbutton'] = '<div id="login">
<button class="login3"><a href= <?php echo base_url()?>index.php/login>login</a> </button>
</div>';
}
and this is my view:
<?php echo $Lbutton ?>
This is Answer:
if ($logged_in)
{
$data['Lbutton'] = '<div id="login">
<button class="login3">'.anchor("pages/logout", "Logout").'</button>
</div>';
}
else
{
$data['Lbutton'] = '<div id="login">
<button class="login3"><a href="'.base_url().'index.php/login" >login</a> </button>
</div>';
}