mysql - PHP keeping session logged on after link -
i have written page displays load of data mysql database , works perfect except when click home link (the title of page) logs out , need log in, im missing stupid or not doing need, code below
<?php session_start(); ?><title>vend365 monitor (beta test)</title> <h1><u><a href="http://www.codeman.org/v365.php">vend 365 online monitor (beta test)</a><p></p></u></h3> <?php require_once ("v365connect.php"); //following if 'update' clicked if (isset($_post['lastseen'])){?><p> <style> table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 1px; text-align: left; } </style> <h1>vend 'last seen' times: page loaded @ <?php echo date("d/m/y g:i:s"); ?></h1> <?php $result1 = mysql_query("select distinct customer vends order customer") or die(mysql_error()); while($row = mysql_fetch_assoc($result1)) { echo '<table><th>'; ?><font size = "5">customer - '<?php echo $row[customer];?>'</font><?php echo '</th>'; $result2 = mysql_query("select * vends customer ='".$row[customer]."'") or die(mysql_error()); while($row1 = mysql_fetch_assoc($result2)) { echo '<tr><td>'; ?>machine <b>'<?php echo $row1[machine];?>'</b> last seen online @ <b>'<?php echo $row1[lastseen];?>'</b> running version <b>'<?php echo $row1[myversion];?>'</b><?php $today = date("d/m/y g:i:s"); $lastseentime = $row1[lastseen]; $diff = $today-$lastseentime; if ($diff == "1"){ ?><b> <font color = "red"> -- last seen online yesterday</font></b> <?php ;} if ($diff > "1"){ ?> <b><font color = "red"> -- last seen online before yesterday</font></b> <?php ;} echo '</td></tr><p>' ; } }?></table> <?php }else{ if (isset($_post['update'])){ if ($_post['checkbox']=='checked'){ $isalive = 1; } else { $isalive = 0; } if ($_post['checkbox1']=='checked'){ $hb800 = 1; } else { $hb800 = 0; } if ($_post['checkbox2']=='checked'){ $hb1100 = 1; } else { $hb1100 = 0; } if ($_post['checkbox3']=='checked'){ $hb1400 = 1; } else { $hb1400 = 0; } if ($_post['checkbox4']=='checked'){ $hb1700 = 1; } else { $hb1700 = 0; } if ($_post['checkbox5']=='checked'){ $gcmreboot = 1; } else { $gcmreboot = 0; } if ($_post['checkbox6']=='checked'){ $emailreboot = 1; } else { $emailreboot = 0; } if ($_post['checkbox7']=='checked'){ $hbgcm = 1; } else { $hbgcm = 0; } if ($_post['checkbox8']=='checked'){ $hbemail = 1; } else { $hbemail = 0; } if ($_post['checkbox9']=='checked'){ $edigcm = 1; } else { $edigcm = 0; } if ($_post['checkbox10']=='checked'){ $ediemail = 1; } else { $ediemail = 0; } if ($_post['checkbox11']=='checked'){ $reportgcm = 1; } else { $reportgcm = 0; } if ($_post['checkbox12']=='checked'){ $reportemail = 1; } else { $reportemail = 0; } if ($_post['checkbox13']=='checked'){ $pingmailgcm = 1; } else { $pingmailgcm = 0; } if ($_post['checkbox14']=='checked'){ $pingmailemail = 1; } else { $pingmailemail = 0; } if ($_post['checkbox15']=='checked'){ $internetgcm = 1; } else { $internetgcm = 0; } if ($_post['checkbox16']=='checked'){ $internetemail= 1; } else { $internetemail = 0; } if ($_post['checkbox17']=='checked'){ $sqlgcm = 1; } else { $sqlgcm = 0; } if ($_post['checkbox18']=='checked'){ $sqlemail = 1; } else { $sqlemail = 0; } if ($_post['checkbox19']=='checked'){ $backupgcm = 1; } else { $backupgcm = 0; } if ($_post['checkbox20']=='checked'){ $backupemail = 1; } else { $backupemail = 0; } $sqlupdate = "update vends set isalive='".$isalive."',customer='".$_post['customer']."',machine='".$_post['machine']."',mailserver='".$_post['smtp']."',emails='".$_post['emails']."',gcm='".$_post['gcm']."',hb800='".$hb800."',hb1100='".$hb1100."',hb1400='".$hb1400."',hb1700='".$hb1700."',sqlserver='".$_post['sqlserver']."',sqlport='".$_post['sqlport']."',sqlinstance='".$_post['sqlinstance']."',sqldatabase='".$_post['sqldatabase']."',sqlname='".$_post['sqlname']."',sqlpassword='".$_post['sqlpassword']."',rebootgcm='".$gcmreboot."',rebootemail='".$emailreboot."',hbgcm='".$hbgcm."',hbemail='".$hbemail."',edigcm='".$edigcm."',ediemail='".$ediemail."',reportgcm='".$reportgcm."',reportemail='".$reportemail."',mailpinggcm='".$pingmailgcm."',mailpingemail='".$pingmailemail."',internetgcm='".$internetgcm."',internetemail='".$internetemail."',sqlgcm='".$sqlgcm."',sqlemail='".$sqlemail."',backupgcm='".$backupgcm."',backupemail='".$backupemail."',lastseen='".$lastseen."' mac='".$_session['mac']."'"; mysql_query($sqlupdate) or die(mysql_error());?><h1> --->customer - <font color = blue><?php echo $_session['customer'];?></font> <br /> --->machine - <font color = blue><?php echo $_session['machine'];?></font> <p> <?php echo "request sent"; } else { //first load screen select customer when correct details entered if (!isset($_post['update'])){ if (!isset($_post['customer'])){ if (!isset($_post['machine'])){ if (isset($_post['submit'])){ $result = mysql_query("select * users user='".$_post['user']."' , pass='".$_post['pass']."'") or die(mysql_error()); $count = mysql_num_rows($result); if ($count == 1){ ?><p><p> <table style="border:1px solid black;"><tr><td><h1>welcome '<?php echo $_post['user'];?>'</td></tr></table><?php $_session['customer']; $_session['machine']; $_session['mac']; if (!isset($_post['customer'])) { if (!isset($_post['machine'])) { echo "<h1><form action ='' method='post'>"; echo "please select customer<br />"; $result1 = mysql_query("select distinct customer vends order customer") or die(mysql_error()); echo "<select name='customer'>"; while($row = mysql_fetch_assoc($result1)) { echo "<option value = '".$row[customer]."'>".$row[customer]."</option>"; } echo "</select>"; echo "<input type='submit' value='go'>"; echo "</form>"; echo ""; echo "show 'last seen' times"; ?> <form method='post'> <input type='submit' value='show last seen status' name ='lastseen' /> </form> <?php } }}else { // if wrong details entered echo "sorry, wrong username or password, please go , try again"; } } else { // following first time load screen ?> <!doctype html> <html> <head> <link rel="stylesheet" type="text/css" href="style-sign.css"> </head><h1> <title>vend 365 monitor</title> <body id="body-color"> <div id="sign-in"> <fieldset style="width:30%"> <legend>log-in here</legend> <form method="post"> user <br><input type="text" style="font-size: 30px;" name="user" size="20"><br> password <br><input type="password" style="font-size: 30px;" name="pass" size="20"><br> <input id="button" type="submit" style="font-size: 30px; "name="submit" value="log-in"> </form> </fieldset> </div> </body> </html> <?php }}} } else { } ?> <?php // select vending machine if (!isset($_post['submit'])){ if (isset($_post['customer'])) { $example = $_post['customer']; $_session['customer'] = $example; $result2 = mysql_query("select * vends customer='".$example."'") or die(mysql_error()); ?><h1> <font color = black>--->customer - <font color = blue><?php echo $_session['customer'];?><p></font></font><?php echo "<form action ='' method='post'>"; echo "please select machine<br />"; echo "<select name='machine'>"; while($row = mysql_fetch_assoc($result2)) { echo "<option value = '".$row[machine]."'>".$row[machine]."</option>"; } echo "</select>"; echo "<input type='submit' value='go'>"; echo "</form>"; }} // show customer/machine info if (isset($_post['machine'])) { $example1 = $_post['machine']; $_session['machine'] = $example1;?> <h1><font color = black>--->customer - <font color = blue><?php echo $_session['customer'];?><br /></font></font><br /><font color = black>--->machine - <font color = blue><?php echo $_session['machine']; ?><p><?php $result3 = mysql_query("select * vends customer='".$_session['customer']."' , machine ='".$_session['machine']."'") or die(mysql_error()); while ($rows = mysql_fetch_assoc($result3)) { $tag1 = $rows['hb800']; $checkedstatus1 = ''; if($tag1 == '1') { $checkedstatus1 = 'checked'; } else { $checkedstatus1 = 'unchecked'; }?><font color = black><form method='post'> 0800 heartbeat check - <input type='checkbox' value='checked' name='checkbox1' <?php echo $checkedstatus1; ?> /> <br /><?php $tag2 = $rows['hb1100']; $checkedstatus2 = ''; if($tag2 == '1') { $checkedstatus2 = 'checked'; } else { $checkedstatus2 = 'unchecked'; }?> 1100 heartbeat check- <input type='checkbox' value='checked' name='checkbox2' <?php echo $checkedstatus2; ?> /> <br /> <?php $tag3 = $rows['hb1400']; $checkedstatus3 = ''; if($tag3 == '1') { $checkedstatus3 = 'checked'; } else { $checkedstatus3 = 'unchecked'; }?> 1400 heartbeat check - <input type='checkbox' value='checked' name='checkbox3' <?php echo $checkedstatus3; ?> /> <br /> <?php $tag4 = $rows['hb1700']; $checkedstatus4 = ''; if($tag4 == '1') { $checkedstatus4 = 'checked'; } else { $checkedstatus4 = 'unchecked'; }?> 1700 heartbeat check - <input type='checkbox' value='checked' name='checkbox4' <?php echo $checkedstatus4; ?> /><br /> <?php $tag5 = $rows['rebootgcm']; $checkedstatus5 = ''; if($tag5 == '1') { $checkedstatus5 = 'checked'; } else { $checkedstatus5 = 'unchecked'; }?> send gcm when rebooted - <input type='checkbox' value='checked' name='checkbox5' <?php echo $checkedstatus5; ?> /><br /> <?php $tag6 = $rows['rebootemail']; $checkedstatus6 = ''; if($tag6 == '1') { $checkedstatus6 = 'checked'; } else { $checkedstatus6 = 'unchecked'; }?> send email when rebooted - <input type='checkbox' value='checked' name='checkbox6' <?php echo $checkedstatus6; ?> /><br /> <?php $tag7 = $rows['hbgcm']; $checkedstatus7 = ''; if($tag7 == '1') { $checkedstatus7 = 'checked'; } else { $checkedstatus7 = 'unchecked'; }?> heartbeat check gcm - <input type='checkbox' value='checked' name='checkbox7' <?php echo $checkedstatus7; ?> /><br /> <?php $tag8 = $rows['hbemail']; $checkedstatus8 = ''; if($tag8 == '1') { $checkedstatus8 = 'checked'; } else { $checkedstatus8 = 'unchecked'; }?> heartbeat check email - <input type='checkbox' value='checked' name='checkbox8' <?php echo $checkedstatus8; ?> /><br /> <?php $tag9 = $rows['edigcm']; $checkedstatus9 = ''; if($tag9 == '1') { $checkedstatus9 = 'checked'; } else { $checkedstatus9 = 'unchecked'; }?> edi fail check gcm - <input type='checkbox' value='checked' name='checkbox9' <?php echo $checkedstatus9; ?> /><br /> <?php $tag10 = $rows['ediemail']; $checkedstatus10 = ''; if($tag10 == '1') { $checkedstatus10 = 'checked'; } else { $checkedstatus10 = 'unchecked'; }?> edi fail check email - <input type='checkbox' value='checked' name='checkbox10' <?php echo $checkedstatus10; ?> /><br /> <?php $tag11 = $rows['reportgcm']; $checkedstatus11 = ''; if($tag11 == '1') { $checkedstatus11 = 'checked'; } else { $checkedstatus11 = 'unchecked'; }?> report fail gcm - <input type='checkbox' value='checked' name='checkbox11' <?php echo $checkedstatus11; ?> /><br /> <?php $tag12 = $rows['reportemail']; $checkedstatus12 = ''; if($tag12 == '1') { $checkedstatus12 = 'checked'; } else { $checkedstatus12 = 'unchecked'; }?> report fail email - <input type='checkbox' value='checked' name='checkbox12' <?php echo $checkedstatus12; ?> /><br /> <?php $gcm = $rows[gcm]; $tag13 = $rows['mailpinggcm']; $checkedstatus13 = ''; if($tag13 == '1') { $checkedstatus13 = 'checked'; } else { $checkedstatus13 = 'unchecked'; }?> ping email server gcm - <input type='checkbox' value='checked' name='checkbox13' <?php echo $checkedstatus13; ?> /><br /> <?php $tag14 = $rows['mailpingemail']; $checkedstatus14 = ''; if($tag14 == '1') { $checkedstatus14 = 'checked'; } else { $checkedstatus14 = 'unchecked'; }?> ping email server email - <input type='checkbox' value='checked' name='checkbox14' <?php echo $checkedstatus14; ?> /><br /> <?php $tag15 = $rows['internetgcm']; $checkedstatus15 = ''; if($tag15 == '1') { $checkedstatus15 = 'checked'; } else { $checkedstatus15 = 'unchecked'; }?> ping internet fail gcm - <input type='checkbox' value='checked' name='checkbox15' <?php echo $checkedstatus15; ?> /><br /> <?php $tag16 = $rows['internetemail']; $checkedstatus16 = ''; if($tag16 == '1') { $checkedstatus16 = 'checked'; } else { $checkedstatus16 = 'unchecked'; }?> ping internet fail email - <input type='checkbox' value='checked' name='checkbox16' <?php echo $checkedstatus16; ?> /><br /> <?php $tag17 = $rows['sqlgcm']; $checkedstatus17 = ''; if($tag17 == '1') { $checkedstatus17 = 'checked'; } else { $checkedstatus17 = 'unchecked'; }?> failed sql ping gcm - <input type='checkbox' value='checked' name='checkbox17' <?php echo $checkedstatus17; ?> /><br /> <?php $tag18 = $rows['sqlemail']; $checkedstatus18 = ''; if($tag18 == '1') { $checkedstatus18 = 'checked'; } else { $checkedstatus18 = 'unchecked'; }?> failed sql ping email - <input type='checkbox' value='checked' name='checkbox18' <?php echo $checkedstatus18; ?> /><br /> <?php $tag19 = $rows['backupgcm']; $checkedstatus19 = ''; if($tag19 == '1') { $checkedstatus19 = 'checked'; } else { $checkedstatus19 = 'unchecked'; }?> backup fail gcm - <input type='checkbox' value='checked' name='checkbox19' <?php echo $checkedstatus19; ?> /><br /> <?php $tag20 = $rows['backupemail']; $checkedstatus20 = ''; if($tag20 == '1') { $checkedstatus20 = 'checked'; } else { $checkedstatus20 = 'unchecked'; }?> backp fail email - <input type='checkbox' value='checked' name='checkbox20' <?php echo $checkedstatus20; ?> /><br /> <u><b><p>details</b></u><p> <?php $_session['mac'] = $rows[mac]; ?> mac address - '<?php echo $_session['mac']; ?>'<br /> customer name - '<?php echo $rows[customer]; ?>'<br /> machine name - '<?php echo $rows[machine]; ?>'<br /> current version - '<?php echo $rows[myversion]; ?>'<br /> gcm app code - <input type='text' value='<?php echo $gcm; ?>' size=150 rows=4 name='gcm' />......<br /> smtp server - '<?php echo $rows[mailserver]; ?>'<br /> email addresses (seperate commas) - '<?php echo $rows[emails]; ?>'<br /><p> <u><b>sql credentials</b></u><p> sql server - '<?php echo $rows[sqlserver]; ?>'<br /> sql port - '<?php echo $rows[sqlport]; ?>'<br /> sql instance - '<?php echo $rows[sqlinstance] ?>'<br /> sql database - '<?php echo $rows[sqldatabase]; ?>'<br /> sql user name - '<?php echo $rows[sqlname]; ?>'<br /> sql password - '<?php echo $rows[sqlpassword]; ?>' <br /><p> <p> <u><b>alive status</u></b><p> last seen online - '<?php echo $rows[lastseen]; ?>'<br /> <?php $tag = $rows['isalive']; $checkedstatus = ''; if($tag == '1') { $checkedstatus = 'checked'; } else { $checkedstatus = 'unchecked'; }?> request 'isalive' status - <input type='checkbox' value='checked' name='checkbox' <?php echo $checkedstatus; ?> /> - send gcm , email if alive.<p> <input type='submit' value='update account details' name ='update' /><p> </form><p> <?php }}}} ?>
Comments
Post a Comment