Jump to content

budimir

Members
  • Posts

    522
  • Joined

  • Last visited

Everything posted by budimir

  1. Try putting on your query ... or die (mysql_error()); So, you will see what exactly is bothering you.
  2. Hey guys, I still haven't solved this problem, can someone help! Can't see what's wrong!
  3. The best way is to make a file, where you specify your database connection, like: $db_server = "localhost"; $db_database = ""; $db_user = ""; $db_pass= ""; // Veza na bazu $veza = mysql_connect($db_server,$db_user, $db_pass) or DIE ('Nisam se uspio spojiti na server'); $veza_baza = mysql_select_db($db_baza,$veza) or DIE ('Nisam uspio odabrati bazu'); And then you include that file on every page where you need to do some queries. And in the end of that file where you have included your connection file you close your connection. mysql_close($name of connection);
  4. How to execute a script when checkbox is clicked??? I don't want to click checkbox and then click on a submit button! I wan't that user clicks on a checkbox and then the script is executed and redirected back to the same page where it have clicked the checkbox.
  5. OK, I have put exit; after every header redirect. Also I have removed session_is_registered() - this is a peace of code I forgot to remove after I did a clean up of session_register(). But still nothing is happening when the browser is shut down or there is a user inactivity. Is there any other way to do this than the way I'm doing it. ??
  6. Hey PFMaBiSmAd, I have checked the variables $korisnicko_ime and $lozinka and they are being set correctly. Also I have echoed all of the querys to make sure that all the variables have the correct values. In the DB session_id is always stored in the correct field. But still, when I shut down the web explorer or after sometime, the data in DB isn't set to 0. I still can't see what's wrong. When I hit logout.php the session is destroyed and the in DB is set to 0. ???? What could be wrong here. check_login.php <?php session_start(); $start=time(); $_SESSION['time_start'] = $start; include ("admin/servis/include/db.php"); // Define $myusername and $mypassword $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $sql="SELECT * FROM korisnici WHERE korisnicko_ime='$myusername' and lozinka='$mypassword'"; $result=mysql_query($sql) or die (mysql_error()); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" $upd = "UPDATE korisnici SET session_id='".session_id()."', aktivan = 'ON' WHERE korisnicko_ime='$myusername' and lozinka='$mypassword'"; mysql_query($upd) or die (mysql_error()); header("location:index_glavni.php"); exit; } else { echo "Upisali ste krivo Korisničko ime ili Lozinku!"; } ?> login_success.php <? session_start(); include ("admin/servis/include/session.php"); $session_id = session_id(); $upit = "UPDATE korisnici SET session_id = '$session_id', aktivan = '0' WHERE korisnicko_ime='$korisnicko_ime' and lozinka='$lozinka'"; $rezultat = mysql_query($upit,$veza) or die (mysql_error()); if(!session_is_registered(myusername)){ header("Location:logout.php"); } else { header("Location:index_glavni.php"); } ?> logoutd.php <?php include ("admin/servis/include/session.php"); session_destroy(); $upit = "UPDATE korisnici SET session_id = '0', aktivan = 'OFF' WHERE korisnicko_ime='$korisnicko_ime' and lozinka='$lozinka'"; $rezultat = mysql_query($upit,$veza) or die (mysql_error()); header("Location:index.php"); ?> session.php <?php session_start(); $session_id = session_id(); include("db.php"); $upit = "SELECT * FROM korisnici WHERE session_id = '$session_id' && aktivan = 'ON'"; $rezultat = mysql_query($upit,$veza) or die (mysql_error()); $row = mysql_fetch_array($rezultat); $user_id = $row["id"]; $ime = $row["ime"]; $korisnicko_ime = $row["korisnicko_ime"]; $prezime = $row["prezime"]; $userData["status"] = $row["status"]; $lozinka = $row["lozinka"]; $status = $row["status"]; $aktivan = $row["aktivan"]; if (!$user_id){ header("Location:../../logout.php"); } $_SESSION['session_time'] = time(); //got the login time for user in second $session_logout = 2000; //it means 15 minutes. //and then cek the time session if($session_logout >= $_SESSION['session_time']){ //user session time is up // update status $upit = "UPDATE korisnici SET session_id = '0', aktivan = 'OFF' WHERE korisnicko_ime='$korisnicko_ime' and lozinka='$lozinka'"; $rezultat = mysql_query($upit,$veza) or die (mysql_error()); //destroy the session session_destroy(); //redirect to login page header("Location:../../../index.php"); } ?>
  7. OK, I see what you're saying. I'm putting in DB the session_id which I'm calling for some things to identify the user and the session. And now I need that is automaticlly set to 0 when loged out (for both cases). That is the problem. I can even restart the computer, and the user will still be logged in. Here is a peace of code for the logout I'm executing: <?php include ("admin/servis/include/session.php"); session_destroy(); $upit = "UPDATE korisnici SET session_id = '0', aktivan = 'OFF' WHERE korisnicko_ime='$korisnicko_ime' and lozinka='$lozinka'"; $rezultat = mysql_query($upit,$veza) or die (mysql_error()); header("Location:index.php"); ?> Any ideas???
  8. Hey guys, I need help with ending sessions. 1.) I wan't to end session when a user closes his web explorer 2.) I wan't to end sesion after some time of users inactivity Can you help me out with this. I have managed to do a logout.php which is called when users pushes a button. But I need to do it automaticlly when one of this two cases happens. Help!!!!
  9. You can do it in many ways... 1.) You can call it by a name and display it in that way 2.) You can select the oldest uploaded picture with that ID and display it But the best thing would that you give us some more details so we can point you to the right direction...
  10. How to pass it through the URL? That's the part I don't understand.
  11. Sorry, not user ID. Let's say Item ID. For instance I have a product and when I click on it I want to see the details about it. But I can't pass an ID for that product.
  12. How to pass an ID to next page??? Which is the most safest way that the ID will be passed on to another page? Please, help!
  13. No, still the same!
  14. 1.) The pregled.php file: <?php include("include/session.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <style type="text/css"> body{ font-size:0.8em; font-family: Trebuchet MS, Lucida Sans Unicode, Arial, sans-serif; margin:0px; padding:0px; } img{ border:0px; } thead td{ font-weight:bold; color:#000; background-color:#E2EBED; } td{ padding:2px; } table{ border:1px solid #000; border-collapse: collapse; } h1{ font-size:1.3em; margin-bottom:0px; } table,h1,p,#ads{ margin-left:10px; } #ads{ margin-top:20px; } /* These classes are used by the script as rollover effect for table 1 and 2 */ .tableRollOverEffect1{ background-color:#317082; color:#FFF; } .tableRollOverEffect2{ background-color:#000; color:#FFF; } .tableRowClickEffect1{ background-color:#F00; color:#FFF; } .tableRowClickEffect2{ background-color:#00F; color:#FFF; } </style> <script type="text/javascript"> /************************************************************************************************************ (C) www.dhtmlgoodies.com, November 2005 This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website. Terms of use: You are free to use this script as long as the copyright message is kept intact. However, you may not redistribute, sell or repost it without our permission. Thank you! www.dhtmlgoodies.com Alf Magne Kalleland ************************************************************************************************************/ var arrayOfRolloverClasses = new Array(); var arrayOfClickClasses = new Array(); var activeRow = false; var activeRowClickArray = new Array(); function highlightTableRow() { var tableObj = this.parentNode; if(tableObj.tagName!='TABLE')tableObj = tableObj.parentNode; if(this!=activeRow){ this.setAttribute('origCl',this.className); this.origCl = this.className; } this.className = arrayOfRolloverClasses[tableObj.id]; activeRow = this; } function clickOnTableRow() { var tableObj = this.parentNode; if(tableObj.tagName!='TABLE')tableObj = tableObj.parentNode; if(activeRowClickArray[tableObj.id] && this!=activeRowClickArray[tableObj.id]){ activeRowClickArray[tableObj.id].className=''; } this.className = arrayOfClickClasses[tableObj.id]; activeRowClickArray[tableObj.id] = this; } function resetRowStyle() { var tableObj = this.parentNode; if(tableObj.tagName!='TABLE')tableObj = tableObj.parentNode; if(activeRowClickArray[tableObj.id] && this==activeRowClickArray[tableObj.id]){ this.className = arrayOfClickClasses[tableObj.id]; return; } var origCl = this.getAttribute('origCl'); if(!origCl)origCl = this.origCl; this.className=origCl; } function addTableRolloverEffect(tableId,whichClass,whichClassOnClick) { arrayOfRolloverClasses[tableId] = whichClass; arrayOfClickClasses[tableId] = whichClassOnClick; var tableObj = document.getElementById(tableId); var tBody = tableObj.getElementsByTagName('TBODY'); if(tBody){ var rows = tBody[0].getElementsByTagName('TR'); }else{ var rows = tableObj.getElementsByTagName('TR'); } for(var no=0;no<rows.length;no++){ rows[no].onmouseover = highlightTableRow; rows[no].onmouseout = resetRowStyle; if(whichClassOnClick){ rows[no].onclick = clickOnTableRow; } } } </script> <title>Servisna mreža</title> <link rel="stylesheet" type="text/css" href="style1.css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> <!-- .style9 {color: #FFFFFF; font-size: 11px; font-weight: bold; } --> </style> </head> <body> <div class="container"> <div class="titleblock"> <br /> <h1>Servisna mreža</h1><p>“Aplikacija za vođenje evidencije o servisima.”</p></div> <div><ul class="navbar"> <li><a href="index.php" class="nav">Servisi</a></li> <li><a href="izvjestaji.php" class="nav">Izvještaji</a></li> <li><a href="popis_servisa_l.php" class="nav">Popis servisa</a></li> <li><a href="naljepnice.php" class="nav">Naljepnice</a></li> <li><a href="poruke/inbox.php" class="nav">Poruke</a></li> <li><a href="../servis/todo.php" class="nav">Taskovi</a></li> </ul></div> <div class="rightcontainer"> <div class="rightbox"> <h2 align="center"><img src="fleche.gif"alt="arrow" /> Najviše posjeta</h2> <?php //Ovdje izvlačim ID najposječenijeg servisa $upit = "SELECT ID,COUNT(*) as highest FROM obilasci GROUP BY ID ORDER BY highest DESC limit 1"; $rezultat = mysql_query($upit,$veza); $broj = mysql_num_rows($rezultat); $i = 0; while ($i<$broj){ $id12 = mysql_result($rezultat,$i,"id"); $highest2 = mysql_result($rezultat,$i,"highest"); echo "Broj obilazaka: <b>$highest2</b>"; $i++; } //Ovdje dobivam ime po ID-u najposječenijeg servisa $upit2 = "SELECT * FROM opcenito where id = '$id12' LIMIT 1"; $rezultat2 = mysql_query($upit2); $broj2 = mysql_num_rows($rezultat2); $i2 = 0; while ($i2<$broj2){ $naziv = mysql_result($rezultat2,$i2,"naziv"); echo "<br/>$naziv"; $i2++; } ?> <h2 align="center"><img src="fleche.gif"alt="arrow" /> Najviše obilazio</h2> <?php $upit = "SELECT * FROM obilasci WHERE upisao = 'Budimir'"; $rezultat = mysql_query($upit,$veza); $broj = mysql_num_rows($rezultat); $upit2 = "SELECT * FROM obilasci WHERE upisao = 'Marijo'"; $rezultat2 = mysql_query($upit2); $broj2 = mysql_num_rows($rezultat2); if ($broj>$broj2){ echo "Budimir - $broj obilaska"; } else { echo "Marijo - $broj2 obilaska"; } ?> <h2><img src="fleche.gif"alt="arrow"/> Pretraživač</h2> <p>Upišite termin koji tražite: </p> <form name="form" action="search.php" method="get"> <input type="text" name="q" /> <input type="submit" name="Submit" value="Traži" /> </form> <h2><img src="fleche.gif"alt="arrow" /> Link</h2> <p><a href="http://server2/" title="Husqvarna.hr">Husqvarna.hr</a><br /> <a href="http://weborder.husqvarna.se/" title="HQ WebOrder">WebOrder</a><br /> <a href="http://support.husqvarna.com/" title="Support Husqvarna">Support-Husqvarna</a><br /> <a href="http://www.support.jonsered.com/" title="Support Jonsered">Support-Jonsered</a><br /> <a href="http://copsupport.husqvarna.com" title="Support-Partner">Support-Partner</a><br /> <a href="http://copsupport.husqvarna.com" title="Support-Flymo">Support-Flymo</a><br /> <a href="http://copsupport.husqvarna.com" title="Support-McCulloch">Support-McCulloch</a><br /> <a href="http://support.automower.com" title="Support-Automower">Support-Automower</a></p> <h2><img src="fleche.gif"alt="arrow" /> Vrijeme i datum</h2> <p> <?php $vrijeme = date("H:i:s"); $datum = date("d.m.Y"); echo "$vrijeme | $datum"; ?> </p> </div> </div> <div class="content"> <p> </p> <table id="myTable" width="1080" height="41" border="0"> <tr> <td width="152" height="15" bgcolor="#CCCCCC"><div align="center" class="style9">Naziv servisa</div></td> <td width="261" bgcolor="#CCCCCC"><div align="center" class="style9">Adresa</div></td> <td width="104" bgcolor="#CCCCCC"><div align="center" class="style9">Grad</div></td> <td width="104" bgcolor="#CCCCCC"><div align="center" class="style9">Telefon</div></td> <td width="113" bgcolor="#CCCCCC"><div align="center" class="style9">Mob</div></td> <td width="170" bgcolor="#CCCCCC"><div align="center" class="style9">Email</div></td> <td width="106" bgcolor="#CCCCCC"><div align="center" class="style9"><u>Opcije</u></div></td> </tr> <?php //Upit na bazu $upit = "SELECT * FROM opcenito WHERE aktivan = 1 ORDER BY naziv ASC"; $rezultat = mysql_query($upit,$veza); $broj = mysql_num_rows($rezultat); $i=0; while ($i < $broj) { $id = mysql_result($rezultat,$i,"id"); $ime = mysql_result($rezultat,$i,"ime"); $prezime = mysql_result($rezultat,$i,"prezime"); $naziv = mysql_result($rezultat,$i,"naziv"); $mb = mysql_result($rezultat,$i,"mb"); $adresa = mysql_result($rezultat,$i,"adresa"); $adresa1 = mysql_result($rezultat,$i,"adresa1"); $ptt = mysql_result($rezultat,$i,"ptt"); $grad = mysql_result($rezultat,$i,"grad"); $zupanija = mysql_result($rezultat,$i,"zupanija"); $sifra = mysql_result($rezultat,$i,"sifra"); $email1 = mysql_result($rezultat,$i,"email1"); $telefon = mysql_result($rezultat,$i,"telefon"); $telefon1 = mysql_result($rezultat,$i,"telefon1"); $fax = mysql_result($rezultat,$i,"fax"); $mob = mysql_result($rezultat,$i,"mob"); $mob1 = mysql_result($rezultat,$i,"mob1"); $email = mysql_result($rezultat,$i,"email"); $web = mysql_result($rezultat,$i,"web"); $napomena = mysql_result($rezultat,$i,"napomena"); $os = mysql_result($rezultat,$i,"os"); $sos = mysql_result($rezultat,$i,"sos"); $soc = mysql_result($rezultat,$i,"soc"); ?> <tr> <script type="text/javascript"> function provjera(href){ var odgovor = confirm('Jeste li sigurni da želite obrisati sve podatke o servisu?'); return odgovor ? window.location = href : false; } </script> <td height="20" class="donja"><?php echo '<a href="detalji.php?id='.$id.'">'?> <?php echo "$naziv"; ?></td> <td class="donja"><?php echo "$adresa"; ?></td> <td class="donja"><?php echo "$grad"; ?></td> <td align="center" class="donja"><?php echo "$telefon"; ?></td> <td align="center" class="donja"><?php echo "$mob"; ?></td> <td class="donja"><?php echo "$email"; ?></td> <td align="center" class="donja"><?php if ($userData["status"] == 3){ echo '<a href="obrisi.php?id='.$id.'" onclick="provjera(this.href); return false;">Obriši</a>';} else { echo "";}?> <?php if ($userData["status"] == 3) { echo '<a href="izmjeni.php?id='.$id.'">Izmjeni</a>'; } else { echo ""; }?></a></td> </tr> <?php $i++; } ?> </table> <hr /> <div align="right"> <?php //Brojanje aktivnih servisa $upit2 = "SELECT * FROM opcenito WHERE aktivan = 1"; $rezultat2 = mysql_query($upit2,$veza); $broj2 = mysql_num_rows($rezultat2); //Brojanje neaktivnih servisa $upit3 = "SELECT * FROM opcenito WHERE aktivan = 0"; $rezultat3 = mysql_query($upit3,$veza); $broj3 = mysql_num_rows($rezultat3); ?> <td><?php echo "Broj aktivnih servisa = $broj2";?></td><br /> <td><?php echo "Broj nekativnih servisa = $broj3";?></td><br /> <td><b><?php echo "Ukupni broj servisa u bazi = $broj";?></b></td> </div> <br /> </div> <script type="text/javascript"> addTableRolloverEffect('myTable','tableRollOverEffect1','tableRowClickEffect1'); addTableRolloverEffect('myTable2','tableRollOverEffect2','tableRowClickEffect2'); </script> <div class="footer"> <div class="right"> <p><?php include ("include/footer.php");?></p> </div> </div> <?php mysql_close($veza);?> </div> </body> </html> 2.) The session.php file: <?php session_start(); $session_id = session_id(); include ("db.php"); $upit = "SELECT * FROM korisnici WHERE session_id = '$session_id'"; $rezultat = mysql_query($upit,$veza) or die (mysql_error()); $row = mysql_fetch_array($rezultat); $user_id = $row["id"]; $ime = $row["ime"]; $korisnicko_ime = $row["korisnicko_ime"]; $prezime = $row["prezime"]; $userData["status"] = $row["status"]; $lozinka = $row["lozinka"]; if (!$user_id){ header ("Location:../../logout.php"); } $_SESSION['session_time'] = time(); //got the login time for user in second $session_logout = 2000; //it means 15 minutes. //and then cek the time session if($session_logout >= $_SESSION['session_time']){ //user session time is up //destroy the session session_destroy(); //redirect to login page header("Location:../../../index.php"); } ?> The error message on the file: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\erp\admin\servis\pregled.php:1) in C:\wamp\www\erp\admin\servis\include\session.php on line 2 Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\erp\admin\servis\pregled.php:1) in C:\wamp\www\erp\admin\servis\include\session.php on line 16
  15. This is how I include session.php: <?php include("include/session.php"); ?>
  16. OK, I get what you mean! But, it's not header which is making problems. The session_start() is causing a problem. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\erp\admin\servis\pregled.php:1) in C:\wamp\www\erp\admin\servis\include\session.php on line 2 I don't understand what is keeping the session_start() from starting
  17. OK, to make it clearer! Session.php is a file where I keep all of my session info (you can see it beneath): <?php session_start(); ob_start(); $session_id = session_id(); include ("db.php"); $upit = "SELECT * FROM korisnici WHERE session_id = '$session_id'"; $rezultat = mysql_query($upit,$veza) or die (mysql_error()); $row = mysql_fetch_array($rezultat); $user_id = $row["id"]; $ime = $row["ime"]; $korisnicko_ime = $row["korisnicko_ime"]; $prezime = $row["prezime"]; $userData["status"] = $row["status"]; $lozinka = $row["lozinka"]; if (!$user_id){ header "Location:../../logout.php"); } $_SESSION['session_time'] = time(); //got the login time for user in second $session_logout = 2000; //it means 15 minutes. //and then cek the time session if($session_logout >= $_SESSION['session_time']){ //user session time is up //destroy the session session_destroy(); //redirect to login page header("Location:../../../index.php"); } ?> I include it to pregled.php (you can see it beneath): <?php include("include/session.php"); ?> I have checked session.php for: output, white spaces, putted session_start() in a first line... So, what else can I check??
  18. session.php is included in every page on the site. But it's only making a problem on that page. Line 16 is with header: if (!$user_id){ header("Location:../../logout.php"); }
  19. An all other pages that file is not making any problems, but on this one it's making big problem. Why???? I tried to edit it once with notepad, and after that I get a problem. Is it connected somehow??
  20. No, not working. This is what happens: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\erp\admin\servis\pregled.php:1) in C:\wamp\www\erp\admin\servis\pregled.php on line 2 Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\erp\admin\servis\pregled.php:1) in C:\wamp\www\erp\admin\servis\pregled.php on line 16
  21. Ok, so I have done like this... It's a begining of the file where I get an error message: <?php ob_start(); session_start(); $session_id = session_id(); include ("include/db.php"); $upit = "SELECT * FROM korisnici WHERE session_id = '$session_id'"; $rezultat = mysql_query($upit,$veza) or die (mysql_error()); $row = mysql_fetch_array($rezultat); $user_id = $row["id"]; $ime = $row["ime"]; $korisnicko_ime = $row["korisnicko_ime"]; $prezime = $row["prezime"]; $userData["status"] = $row["status"]; $lozinka = $row["lozinka"]; if (!$user_id){ header("Location:../../logout.php"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <style type="text/css"> ..... This is the error message I'm getting: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\erp\admin\servis\pregled.php:1) in C:\wamp\www\erp\admin\servis\pregled.php on line 3 Any ideas????
  22. No, still not working! What the hell....? ??? What else could it be?? When I'm including a file, session_start() is the first line of the included file. There is no output, there is no white spaces but, I'm getting an error message. Could it be that something is preventing session_start() from starting????
  23. 1.) Start_session is at a first line of code 2.) There is no white spaces in a whole session.php and also no output 3. ) ob_start is not helping What else could be wrong????
  24. Hey Guys, I'm constantly getting an error message like this: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\erp\admin\servis\pregled.php:1) in C:\wamp\www\erp\admin\servis\include\session.php on line 2 I have checked for the output, whiote spaces, etc. But I couldn't solve the problem. Can someone, please, take a look and tell me what's wrong??? I can't see it! I have attached pregled.php where I'm getting the error message, and I have attached session.php which I include in pregled.php and in which I'm keeping all the data for the session. Please help!!!!! [attachment deleted by admin]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.