Jump to content

techker

Members
  • Posts

    812
  • Joined

  • Last visited

Everything posted by techker

  1. ya they are logged in already. how can i echo the user that just loggin?
  2. no im thinking of this.. <?php if(isset($submit)) { session_destroy(); } ?>
  3. would this be good? <?php session_start(); if(!session_is_registered(myusername)){ header("location:index.php"); session_destroy(); } ?>
  4. why is that?
  5. hey guys i have a script i did and i need help with my logout? im using sessions. <?php session_start(); if(!session_is_registered(myusername)){ header("location:index.php"); }?>
  6. hey guys i have a login script that i have and it was working fine intill tonight? when i try to login it says header already sent... what i think it is is that is my buddy loggin today afther me?? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Admin Sourlfitness</title> <style type="text/css"> <!-- body { background-image: url(images/about_03.jpg); } --> </style></head> <body> <table width="602" height="207" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td width="602" height="130"><img src="images/logo.jpg" width="212" height="130" /></td> </tr> <tr> <td height="77"><?PHP include ("../functions2.php"); // the Default function. //note for functions: if you want to include a value of some variables inside the funtions, //then you have to GLOBAL it first. function index($admin) { global $db, $prefix; //check if the user is logged in or not. if (is_logged_in_admin($admin)) { include("header.php"); //if the user is logged in then read the cookies. $cookie_read = explode("|", base64_decode($admin)); //define variables to hold cookie values. $adminid = $cookie_read[0]; $admin_name = $cookie_read[1]; $password = $cookie_read[2]; $ipaddress = $cookie_read[3]; $lastlogin_date = $cookie_read[4]; $lastlogin_time = $cookie_read[5]; //print welcome message echo "Welcome <b>$admin_name</b>, Last login from: [$ipaddress] on [$lastlogin_date @ $lastlogin_time] (<a href=index.php?maa=Logout>Logout</a>)"; echo "<br><br><br><br>"; nav_menu(); include("footer.php"); }else{ //if the user is not logged in then show the login form. // header("Location: index.php?maa=Login"); die(); include("header.php"); login_form(); include("footer.php"); } } ################################################################################ #------------------------------------------------------------------------------# # login #------------------------------------------------------------------------------# ################################################################################ //the login form function login_form(){ global $admin_name,$admin_err,$pass_err,$error_msg; echo "<center><font class=\"title\">Please enter your admin name and password to log in.</font></center>\n"; echo " <center> <form method=\"POST\" action=\"index.php\" name=\"loginform\"> <table border=\"0\" cellspacing=\"2\" cellpadding=\"4\"> <tr> <td bgcolor=\"#E2E2E2\">admin name: </td> <td bgcolor=\"#E2E2E2\"><input type=\"text\" name=\"admin_name\" value=\"$admin_name\" size=\"11\"> $admin_err</td> </tr> <tr> <td bgcolor=\"#E2E2E2\">Password: </td> <td bgcolor=\"#E2E2E2\"><input type=\"password\" name=\"password\" size=\"11\"> $pass_err</td> </tr> <tr> <td> </td> <td> <input type=\"hidden\" name=\"maa\" value=\"do_login\"> <input type=\"submit\" value=\"Login\"></p> </td> </tr> </table> $error_msg </form> [ <a href=\"index.php?maa=Forgot_pwd\">Forgot password?.</a> ]<br><br>"; } //a login function to call the login form. function Login(){ include("header.php"); login_form(); include("footer.php"); } //this function will do the login for you. function do_login(){ global $prefix,$db,$admin_name,$password, $remember, $admin_err,$pass_err,$error_msg,$REMOTE_ADDR; //check admin name and password fields. if((!$admin_name) || (!$password)){ include("header.php"); $reqmsg= "(<font class=error>Required!</font>)"; if(trim(empty($admin_name))){ $admin_err= $reqmsg; } if(empty($password)){ $pass_err= $reqmsg; } //$error_msg = "<center><font class=\"error\">Error:</font></center>\n"; login_form(); include("footer.php"); exit(); } //encyrpt password for more Security $md5_pass = md5($password); $sql = mysql_query("SELECT * FROM ".$prefix."_admin WHERE admin_name='$admin_name' AND password='$md5_pass'"); $login_check = mysql_num_rows($sql); /////////////////////////////////////////////////////////////////////// if($login_check > 0){ while($row = mysql_fetch_array($sql)){ $adminid = $row['adminid']; $admin_name = $row['admin_name']; $password = $row['password']; $ipaddress = $row['ipaddress']; $lastlogin = explode(" ", $row['lastlogin']); $lastlogin_date = $lastlogin[0]; $lastlogin_time = $lastlogin[1]; $info = base64_encode("$adminid|$admin_name|$password|$ipaddress|$lastlogin_date|$lastlogin_time"); setcookie("admin","$info",0); mysql_query("UPDATE ".$prefix."_admin SET ipaddress='$REMOTE_ADDR', lastlogin=NOW() WHERE adminid='$adminid'") or die (mysql_error()); msg_redirect("Login success please wait..........","index.php","2"); //header("Location: index.php"); }//end while }else{ //include("header.php"); $error_msg = "<font class=error>Login error. Please check admin name/password.</font>"; unset($admin_name); unset($password); include("header.php"); login_form(); include("footer.php"); exit(); } } ################################################################################ #------------------------------------------------------------------------------# # logout #------------------------------------------------------------------------------# ################################################################################ function Logout($admin) { unset($admin); unset($cookie); setcookie("admin", false); $admin = ""; header("Location: index.php"); } ################################################################################ #------------------------------------------------------------------------------# # Forgot Password #------------------------------------------------------------------------------# ################################################################################ function Forgot_pwd_form(){ global $error_msg; echo "<center><font class=\"title\">Send me a new password</font> <form method='POST' action='index.php'> <table border='0' cellpadding='4'> <tr> <td bgcolor='#E2E2E2'>admin name:</td> <td bgcolor='#E2E2E2'><input type='text' name='admin_name' size='11'></td> </tr> <tr> <td bgcolor='#E2E2E2'>Email:</td> <td bgcolor='#E2E2E2'><input type='text' name='email' size='11'></td> </tr> <tr> <td> </td> <td> <input type='hidden' name='maa' value='do_Forgot_pwd'> <input type='submit' value='Send password'></p> </td> </tr> </table><center>$error_msg</center> </form>"; } function Forgot_pwd(){ global $admin, $prefix, $db; include("header.php"); Forgot_pwd_form(); include("footer.php"); } function do_Forgot_pwd(){ global $admin, $prefix, $db, $email, $admin_name, $error_msg, $site_name ,$site_email, $site_url; $result = mysql_query("SELECT * FROM ".$prefix."_admin WHERE admin_name='$admin_name' AND email='$email'"); $check = mysql_num_rows($result); if($check == 1){ function new_pwd() { $chars = "abchefghjkmnpqrstuvwxyz0123456789"; srand((double)microtime()*1000000); $i = 0; while ($i <= 7) { $num = rand() % 33; $tmp = substr($chars, $num, 1); $pwd = $pwd . $tmp; $i++; } return $pwd; } $new_pwd = new_pwd(); $md5_password = md5($new_pwd); $sql = mysql_query("UPDATE ".$prefix."_admin SET password='$md5_password' WHERE email='$email'"); $subject = "New password"; $message = " Hello $admin_name, You are receiving this email because you have (or someone pretending to be you has) requested a new password be sent for your account on $site_name. Here it is below. -------------------------- admin name: $admin_name Password: $new_pwd -------------------------- You may login below: $site_url You can of course change this password yourself via the profile page. If you have any difficulties please contact the webmaster. -- -Thanks $site_name This email was automatically generated. Please do not respond to this email or it will ignored."; mail($email,$subject,$message, "FROM: $site_name <$site_email>"); include("header.php"); echo "Your New Pass has been emailed to your email."; echo "<br>please wait..."; include("footer.php"); }else{ include("header.php"); Forgot_pwd_form(); echo "<center><font class=\"error\">Error: Wrong admin name/email</font></center><br>"; include("footer.php"); } } ################################################################################ #------------------------------------------------------------------------------# # a switch for switching between functions #------------------------------------------------------------------------------# ################################################################################ switch ($maa){ case "Forgot_pwd": Forgot_pwd(); break; case "do_Forgot_pwd": do_Forgot_pwd(); break; case "Register": Register(); break; case "do_Register": do_Register(); break; case "Logout": Logout($admin); break; case "Login": Login(); break; case "do_login": do_login(); break; Default: index($admin); Break; } ?></td> </tr> </table> <p> </p> </body> </html>
  7. lol im just asking for help.cause i freez on that part.thx
  8. it works a pop up apears and show the user i select. but what i need is to grab the user selected profile in my database.
  9. not really its not working ..
  10. hey thanks dude i just got to debug it..the select box part works fine but the las part <?php if(!empty($username)) { $q = mysql_query("SELECT * FROM `authuser` WHERE `username`='".$username."'") $r = mysql_fetch_array($q); echo $r['username']; //rest of your user data.... } ?> gives me errors
  11. i guess?but where i bug is how would i do it so it can get the selected user
  12. in the select box it is populated with user name in my db.now i want to when i select a user it show his profile.
  13. its good but i need the part were it gets the select name?
  14. i just need to retreive the user from my database
  15. hey guys i got to the part were it populates my select box.but i need to echo what i select? <? // Connect database mysql_connect("localhost","techker_","o"); mysql_select_db("o_test"); ?> <select name="categoryID"> <? $sql = "SELECT name FROM authuser ". "ORDER BY name"; $rs = mysql_query($sql); while($row = mysql_fetch_array($rs)) { echo "<option value=\"".$row['name']."\">".$row['name']."\n "; } ?> </select>
  16. and works for me to!lol thx buddy..do you know what i was doing wrong?
  17. hey guys my query works fine like this $q = "SELECT * FROM events"; $res = mysql_query($q); $row = mysql_fetch_assoc($res); echo (empty($row['d'])? "empty": "not empty"); now when i add a link to a page that will show the description in deatails i add $id=$_POST['id']; $q= "SELECT * FROM events WHERE id = ".$_GET['id']." LIMIT 1 ,30 "; $res= mysql_query($q); $row= mysql_fetch_assoc($res); the get it..it give my empty all the time?
  18. ya its good thx
  19. hey guy i have this script that inputs in a db how many times you done this week.. so i made a page that views the hours and i would like to but an if in every query that if there is nothing in the db output OFF this is my query $query3 = "SELECT COUNT(*) AS TotalCount, `to_t2` - `from_t2` AS TotalNumber, SUM( `to_t2` - `from_t2`) AS Totalhours FROM `week2`GROUP BY `from_t2` "; $result3 = mysql_query($query3) or die(mysql_error()); can i add an order by even if there is a group by?
  20. ok i got it going..but is there a way to limit the amout of words shown in my description?so when he clicks more info it shows the hole thing?
  21. thats what i need..cause the code is good but the view is not.think you can help with the css?
  22. did you see the link
  23. hey guys im doing a car dealer site for my budy and im trying to figure out a page to show multible cars inventory page.. i got this going but it is now showing the second query right? <?php $QQQ = mysql_query("SELECT * FROM employees"); if (!$QQQ) die(mysql_error()); // Get the total number of rows $total_items = mysql_num_rows($QQQ); // Get the page limit & page $limit = $_GET['limit']; $page = $_GET['page']; // Do default setting if((!$limit) || (is_numeric($limit) == false) || ($limit < 1) || ($limit > 5)) { $limit = 2; //default } // Do default setting if((!$page) || (is_numeric($page) == false) || ($page < 0) || ($page > $total_items)) { $page = 1; //default } // Calculate the number to page to display $total_pages = ceil($total_items / $limit); $set_limit = $page * $limit - ($limit); $QQQ1 = mysql_query("SELECT * FROM employees LIMIT $set_limit, $limit "); if(!$QQQ1) die(mysql_error()); $err = mysql_num_rows($QQQ1); if($err == 0) die("No matches met your criteria."); // Let user decide how many result to show in each page // echo "Results per page: "; //echo "<a href='list_store.php?limit=2&page=1'>2</a> | //<a href='list_store.php?limit=5&page=1'>5</a> | //<a href='list_store.php?limit=10&page=1'>10</a>"; //Count Message $count = 1; //to loop the results into the table rows code goes here //while($FFF = mysql_fetch_assoc($QQQ1)) { ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- body { background-image: url(images/index_23.gif); } --> </style></head> <body> <table width="515" height="346" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="515" height="346" valign="top" background="images/admin_mid_m.jpg"><table width="506" height="140" border="1" align="center" cellpadding="0" cellspacing="0"> <tr><?php while ($info=mysql_fetch_array($QQQ1)) {?> <td width="209" height="105" rowspan="6"><div align="center"><?php echo '<img src="/ADMIN/pics/'. $info['thumb'] .'" border="0" alt="" /> <br />'; ?></div></td> </tr> <tr> <td colspan="2"><div align="center"><?php echo $info['name'] ?>-<?php echo $info['email'] ?></div></td> <td> </td> </tr> <tr> <td height="23" colspan="2"><strong>Numero de commande:<?php echo $info['numero'] ?></strong></td> <td width="87"> </td> </tr> <tr> <td height="60" colspan="2"><?php echo $info['description'] ?></td> <td> </td> </tr> <tr> <td height="29" colspan="2"><strong>Sold </strong>:<?php echo $info['sold'] ?></td> <td height="29"> </td> </tr> <?php } ?> </table> <p><table width="194" border="1" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td width="194"><div align="center"> <?php $prev_page = $page - 1; if($prev_page >= 1) { echo(" <a href=index_view.php?limit=$limit&page=$prev_page><b>Prev</b></a>"); } for($i = 1; $i <= $total_pages; $i++){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"index_view.php?limit=$limit&page=$i\">$i</a> "); } } $next_page = $page + 1; if($next_page <= $total_pages) { echo("</b><a href=index_view.php?limit=$limit&page=$next_page><b>Next</b></a> "); } //dbDisconnect($conn2); ?></td> </tr> </table></p></td> </tr> </table> </body> </html> this is whats it showing. http://www.canada-auto.com/new/inv_inc.php
  24. techker

    if question

    <? if (mysql_affected_rows == 0) { echo "Off"; } else { while($row = mysql_fetch_array($result9)) { echo $row['Totalhours'] ." H"; } } ?>
  25. techker

    if question

    its the line that you made.
×
×
  • 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.