Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. Add an extra column to your users table of type timestamp and upon registration: INSERT INTO users SET registration_date = NOW(), expiration_date = DATE_ADD(NOW(), INTERVAL 1 MONTH), ..registration data Then when a user logs in: <?php if (date('U', $row['expiration_date']) > time()) { // expired // expiration logic } ?>
  2. login_form.php <?php require_once('csrf.php'); ?> <?php if (!empty($_GET['errors'])): ?> <ul> <li><?php print implode("</li>\n\t<li>", explode(';', $_GET['errors'])); ?></li> </ul> <?php endif; ?> <form action="login_process.php" method="post"> <input type="hidden" name="csrf" value="<?php print $_SESSION['csrf']; ?>"> <label>Username: <input type="text" name="username"></label> <label>Password: <input type="password" name="password"></label> <input type="submit" value="Login"> </form> login_process.php <?php error_reporting(0); // set to E_ALL if under development ini_set('display_errors', FALSE); // set to TRUE if under development if (!empty($_POST)) { if (empty($_POST['csrf'])) { session_destroy(); header('Location: login_form.php'); } $csrf = $_POST['csrf']; if (!strcmp($csrf, $_SESSION['csrf']) || $_SESSION['csrf_ttl'] < time()) { session_destroy(); header('Location: login_form.php'); // re-creates the session and the csrf } $username = htmlentities($_POST['username']); $password = htmlentities($_POST['password']); $errors = array(); if (!ctype_alnum($username)) { $errors[] = 'Username should only contain alphanumeric characters'; } if (sizeof($errors)) { $errors = implode(';', $errors); header("Location: login_form.php?errors=$errors"); } require_once('connect2db.php'); $query = 'SELECT * FROM users WHERE username=\'%s\' AND password=sha1(\'%s\')'; $fquery = sprintf($query, $username, $password); $result = mysql_query($fquery, $db); $total_result_rows = mysql_num_rows($result); if ($total_result_rows === 1) { require_once('getip.php'); require_once('sessions.php'); $_SESSION['username'] = $username; $_SESSION['userip'] = sha1(getip()); $_SESSION['useragent'] = sha1($_SERVER['HTTP_USER_AGENT']); } else {// 0: username, password match not found; 1+: multiple matches found, ambiguous $errors = 'Username and/or password are incorrect'; header("Location: login_form.php?errors=$errors"); } } else { header('Location: login_form.php'); } ?> verify_login.php <?php require_once('getip.php'); require_once('sessions.php'); if (!empty($_SESSION['useragent']) && (!strcmp($_SESSION['useragent'], sha1($_SERVER['HTTP_USER_AGENT'])) || !strcmp($_SESSION['userip'], sha1(getip()))) { // 1: same session, different browser? 2: ip changed? session_destroy(); header('Location: login_form.php'); } ?> Then on your login protected pages: <?php require_once('verify_login.php'); //protected page content ?>
  3. Right and then he will be coming back asking why he gets: Notice: Undefined index: user Notice: Undefined index: rank Or why after he logs in he is being redirected to the login after going to a login protected page.
  4. $PHPSESSID = session_id(); after session_start();
  5. <?php $i = 0; $cities_per_column = 500; print '<table><tr>'; while ($row = @mysql_fetch_assoc($result)){ print '<td><a href="page.html">', strtr($row['city'],$arr) ,'</a></td>'; ++$i; if (!($i % $cities_per_column)) { print '</tr><tr>'; } } print '</tr></table>'; ?> Creates columns of each 500 cities.
  6. 1) resize the image using a resizing script 2) use the width and height attributes of the img element Technically we can't help you on this one as this is html/css related and we are talking php here It's not padding but margin. Add a style attribute with the margin defined (like so: <img style="margin: .." ..>) If this doesn't work you may need to modify the display setting (<img style="margin: ..; display: block" ..>.
  7. Depends on what you want to do. If you need an input field on your website you need the text field. If you on the other hand want to expand your current stored data (for example add a new user directly to your database) you insert a new record.
  8. Depends on what you want in the first column and what you want in the second column. You may need to create a separate query for this to work.
  9. I thought you would now what to do with them. <?php $nameF = $_POST['nameF']; $eMail = $_POST['eMail']; echo "<meta http-equiv=\"refresh\" content=\"2;url=https://secure.xxx.com/xxx.org/success.php?nameF=$nameF&eMail=$eMail\"/>"; ?>
  10. $ttarget2 = $ttarget1 . $_SESSION['id'] . '.jpg'; Note the . before jpg
  11. ignace

    search

    SELECT * FROM crackz WHERE (name = '$name' OR name LIKE '%$name%') AND (type = 'Games' OR type = 'Movies')
  12. https://secure.xxx.com/xxx.org/success.php?nameF=<nameF>&eMail=<eMail> should be: https://secure.xxx.com/xxx.org/success.php?nameF=$_POST['nameF']&eMail=$_POST['email']
  13. A text field is a piece (single-line text entry) of a form. A record is one row of a (db) table.
  14. Sorry I made a mistake. My suggested solution was a second row instead of a second column. This code now creates a second column. <table style="width: 630px"> <tbody> <tr> <td style="height: 500px"> <div style="width: 50%; height: 100%; overflow: auto;"> <ul> <?php foreach ($datacol1 as $value) { print "<li>$value</li>"; } ?> </ul> </div> </td> <td> <div style="width: 50%; height: 100%; overflow: auto;"> <ul> <?php foreach ($datacol2 as $value) { print "<li>$value</li>"; } ?> </ul> </div> </td> </tr> </table>
  15. ignace

    search

    I mean your tables (name + columns)
  16. connect to database first? Edit: Nevermind, got it. I thought mysql_real_escape_string() could operate independently of a db connection.
  17. Yes it will. If that is a problem you can alter it to POST if you use a form.
  18. <table style="width: 630px"> <tbody> <tr> <td style="height: 500px"> <div style="width: 50%; height: 100%; overflow: auto;"> <ul> <li><a href="/VT/Adamant.html">Adamant, VT</a></li> <li><a href="/VT/Albany.html">Albany, VT</a></li> <li><a href="/VT/Alburg.html">Alburg, VT</a></li> <li><a href="/VT/Arlington.html">Arlington, VT</a></li> <li><a href="/VT/Ascutney.html">Ascutney, VT</a></li> </ul> </div> </td> </tr> <!-- second column --> <tr> <td style="height: 500px"> <div style="width: 50%; height: 100%; overflow: auto;"> <ul> <li><a href="/VT/Adamant.html">Adamant, VT</a></li> <li><a href="/VT/Albany.html">Albany, VT</a></li> <li><a href="/VT/Alburg.html">Alburg, VT</a></li> <li><a href="/VT/Arlington.html">Arlington, VT</a></li> <li><a href="/VT/Ascutney.html">Ascutney, VT</a></li> </ul> </div> </td> </tr> </tbody> </table>
  19. did you use this format? success.php?nameF=<nameF>&eMail=<eMail>
  20. $id = empty($_POST['id']) ? 'NULL' : $_POST['id'];
  21. You are using the wrong html element. If you want to work with columns you need a table.
  22. Using of the below two methods: 1) point your form to that file ($_POST or $_GET). 2) use the superglobal $_GET to pass these variables
  23. Wrong section. Here's a cheat sheet: http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/
×
×
  • 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.