PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
session_start();
$emailadd = $_SESSION['Emailadd'];
$hostname="xxxxxxxxxxxxxxxxxxx";
$username="xxxxxxxxxxxxxxxxxxxxxx";
$password="xxxxxxxxxxx";
$database="xxxxxxxxxxxxxxxxxxxxxxxxxx";
$on = 'yes';
$off = 'no';
$ac = 'yes';
mysql_connect($hostname, $username, $password) OR DIE("Unable to connect");
mysql_select_db("xxxxxxxxxxxxxx") or die("Unable to select database");
$query="update Account SET On='" . $off . "' WHERE Accepted='" . $ac . "'";
$checkresult = mysql_query($query);
$query="update Account SET On='" . $on . "' WHERE Accepted='" . $ac . "'";
$checkresult = mysql_query($query);
if ($checkresult) header('Location:login.html');
else echo 'update query failed';
mysql_close();
?>
Wrong? i would like to have codes that output is .. if a DJ login. the other will be offair(all except the new Loggedin DJ) then he will be onair.
Last edited by Benjamin on Tue Nov 22, 2011 7:23 am, edited 1 time in total.
Reason:Added [syntax=php||htm||css||javascript||sql||etc] - Please use [syntax] tags when posting code in the forums! Thanks.
yes. not logsin actualy.. i want a page that have a button. if he is onair. the button named Offair. then if he click offair button. the value in the databse will be 'no' (mean to be offline) then the button in the same page will be renamed to Onair. if he click onair, their is condition. if other DJ is online it is forced to be offair by changing the value in database.
//On every request
mysql_connect($hostname, $username, $password) OR DIE("Unable to connect");
mysql_select_db("xxxxxxxxxxxxxx") or die("Unable to select database");
$query="update Account SET On='" . $off . "'; //set all to "offair"
$result = mysql_query($query);
$query="update Account SET On='" . $on . "' WHERE Accepted='" . $emailaddr . "'"; //set "onair" only to the one with given email addres
$result = mysql_query($query);
//you can do some additional checks on $result and redirect