Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. Don't he better check if selected database exists then remove "or die()" ? Yep, but not by using or die().
  2. $languageDirectory = '/path/to/languages/directory'; $languageFile = "lang.$lang.php"; require_once $languageDirectory . DIRECTORY_SEPARATOR . $languageFile; Login has nothing to do with it.
  3. I know I made the mistake first, but I believe for the query to work you even need to list all select fields in the group by clause, thus: select count(work) as total, work, name from tablename group by total, work, name Edit: Nope, checked it. And is the 'work' necessary for the order by? As group by already put it all together so work won't show up double for name thus leaving the work order by unneccessary?
  4. Use this: if (!empty($_GET['master_id'])) Validate using: ctype_digit($_GET['master_id']) /*or*/ is_numeric($_GET['master_id']) /*or*/ $id = (int) $_GET['master_id'] For input data which should have a minimum length use: if (isset($display_name[3])) Where 3 defines the minimum length of $display_name
  5. What if i pass lang=alien? Then it would load no language at all.. require_once '/path/to/default/language.php'; // in case lang defines a non-supported language $LangFile = "lang.".$LangCode.".php"; //ie lang.en.php if(file_exists($LangFile)) require_once $LangFile; // overwrites the default language.
  6. 1) Posted in the wrong section. 2) Forget my suggestion, won't work. 3) Read the contents of your cookie using firefox and some plugin which reads cookie data.
  7. It's an sql query to perform on your db to get the results.
  8. $email = array(); $sizeof = sizeof($list); for ($i = 1; $i <= $sizeof; ++$i) { if (!($i % 4)) { print implode(', ', $email); $email = array(); } $email[] = $list[$i - 1]; mail(..); }
  9. Read the contents of your cookie and check for how long it is set. Or ouput the time using session_get_cookie_params() and if ttl is still 0 then session_destroy() when you login: session_start(); if (sizeof($_SESSION)) { session_destroy(); } ..
  10. SELECT name, work, count(*) as work_times FROM table GROUP BY work
  11. <?php if (isset($_POST['submit'])) { require_once('db_connect.php'); if (empty($_POST['email'])) { echo "didnt enter EMAKL<br />"; } else { $e = trim($_POST['email']); } if (empty($_POST['pass'])) { echo "Didnt enter PASS<br />"; } else { $p = trim($_POST['pass']); } if ($e && $p) { $q = "SELECT user_id, first_name, user_level FROM users WHERE email='$e' AND pass=SHA1('$p')"; $r = mysqli_query($dbc, $q) or trigger_error("Couldnt execute query 1"); if (mysqli_num_rows($r) == 1) { if(isset($_POST['remember'])) { session_set_cookie_params(86400); } session_start(); $_SESSION = mysqli_fetch_array($r); setcookie("cookid", $_SESSION['user_id'], time()+60*60*24*100); setcookie("cookname", $_SESSION['first_name'], time()+60*60*24*100); setcookie("cooklevel", $_SESSION['user_level'], time()+60*60*24*100); header("Location: index.php"); exit(); } else { echo "Youre not in hte DB<br />"; } } } ?> <!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>Untitled Document</title> <style type="text/css"> <!-- .style2 {color: #333333} .style3 {color: #ECE9D8} --> </style> </head> <body> <p><a href="register.php">Register</a> <a href="login.php">Login</a> <a href="password.php">Change Password</a> <a href="view_users.php">View Users</a> <a href="private.php">private</a></p> <h1>Login</h1> <form action="login.php" method="post"> <input type="text" name="email" /> <input type="text" name="pass" /> <input type="submit" name="submit" value="Login" /> <label> <input type="checkbox" name="remember" id="remember" /> Remember me:</label> </form> </body> </html> I also took the liberty to format your code to something more readable.
  12. echo "ERROR: " . mysql_error(); is always executed, wrap a conditional around it: if (!$result) { echo "ERROR: " . mysql_error(); } Where's the mysql_connect() and mysql_select_db() part?
  13. $queryLog = array(); $query = 'SELECT * FROM table'; $result = mysql_query($query, $db); if ($result) { $queryLog[] = $query; .. } // get last executed query: print array_pop($queryLog);
  14. Yes, however you will need eval() to re-create the function
  15. <input type="checkbox" name="session_lifetime" value="remember_me"> if (!empty($_POST['session_lifetime'])) { session_set_cookie_params(86400);//24 hours } session_start();
  16. Create an association table: ingstr=string ouseh=house incepr=prince Remove the ay and then query your db. As you can't identify how many need to be removed from the end and prepended.
  17. Where in your browser or txtfile.txt? Please post your script again I'm guessing you removed <?php Mike how many hours of experience do you have with php? Please learn php first.
  18. http://be2.php.net/manual/en/function.session-set-cookie-params.php Default is 0 which means until the browser is closed.
  19. Yes and move the Athy Register.pdf to your directory where your .php file resides.
  20. It's feasible, not usable. To accomplish this you would need javascript (key listener) and ajax (to submit the new value to php)
  21. $firstword = array_shift($pnm); $secondword = array_shift($pnm); $pnm = implode('', array($firstword, $secondword)) . ' ' . implode(' ', $pnm);
  22. $scandir = scandir('/path/to/directory'); do { $file = array_rand($scandir); } while (!is_file($file)); $dir . $file is unneccessary as $file already has the directory prepended.
  23. If you enter define:plugin as a search term into google you'll get an explanation of what a plugin actually is, simply put: it's something a system hasn't yet have. I never created a plugin system myself and my best guess would be that a plugin would be registered for a particular section in your website, then when you enter that particular section it calls all registered plugins (somewhat like an observer pattern, i guess) and passes it's contents. But, like I said I never created it myself before, maybe someone who wants to add something to that?
  24. if (!empty($_POST)) { if (empty($_POST['field'])) { $errors[] = 'field=empty'; } else { //field is not empty } .. if (sizeof($errors)) { print 'errors'; } else { //process } }
×
×
  • 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.