Jump to content

pneudralics

Members
  • Posts

    241
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

pneudralics's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. I hired a coder to build me a small section for a website. I've never seen the * used before and was just wondering what it meant. print $user."*".$id;
  2. Make sure the links submitted matches a pattern
  3. Not trying to break the url apart. I just want to be able to match: http://www.phpfreaks.com/forums/index.php? (and 20-100 more characters afterwards)
  4. I can't seem to get the match after: http://www.phpfreaks.com/forums/index.php? I want to be able to check for at least 20 characters to 100 and the allowed characters are in []. The text string will always be: http://www.phpfreaks.com/forums/index.php? preg_match ('|^http://www.phpfreaks.com/forums/index.php?[A-Za-z0-9._=&?]{20,100}$|', $link)
  5. Are you talking more about generating a unique id other than an autoincrement one? If so I usually do it in my registration. I'll add the email to the database so it'll get an autoincrement id. I then hash the email and add the autoincrement id to the end of my newly hash email to make sure no one will ever get the same unique id. I then just update my uniqueid field.
  6. Here's what I would do... I'm sure there are way better ways to do it but I think it'll get the job done. 1. Create a field in the database and name it something like lastlink 2. Include a file on every page. All that file does is update the current url to the user's lastlink field. Everytime a user clicks to go somewhere on the website it'll reactivate that file and therefore it'll update the lastlink field. 3. Once cookie dies and user logs in, just make it redirect to the url in lastlink. That's just the gist of it. I'm sure you want to add more things to it.
  7. http://www.heaveninteractive.com/weblog/2008/03/17/using-actionscript-30-with-php-part-1/
  8. I don't know anything about timthumb.php. I do see everything fine in FF and it actually loads up quick. It took a while on IE8 to load but I can't see the images.
  9. I have an "idea"...what if you record the url of the last page the user was on? Once the cookie dies and the user is required to login just redirect it to the last page from the database..
  10. I want to start focusing on making cleaner looking codes. How can I make the below look cleaner? <?php $ip = $_SERVER['REMOTE_ADDR']; if (isset($_POST['submit'])) { //Do some filtering $email = mysql_real_escape_string(htmlentities(strip_tags(trim($_POST['email'])))); $name = mysql_real_escape_string(htmlentities(strip_tags(trim($_POST['name'])))); $password = mysql_real_escape_string(htmlentities(strip_tags(trim($_POST['password'])))); $confirmpassword = mysql_real_escape_string(htmlentities(strip_tags(trim($_POST['confirmpassword'])))); //If cookie is not set then we allow form to be submit if (!isset($_COOKIE['registerform'])) { if (!empty ($_POST['agree'])) { if (!empty ($_POST['email'])) { if (preg_match ('/^[A-Za-z0-9._]{1,100}@[A-Za-z0-9._]{1,100}\.[A-Za-z0-9]{1,100}$/', $email)) { //Check for duplicate emails $query = "SELECT * FROM user WHERE email = '$email' LIMIT 1"; if ($result = mysql_query ($query)) { while ($row = mysql_fetch_array ($result)) { $emailcheck = $row['email']; } } if ($email != $emailcheck) { if (!empty ($_POST['name'])) { if (preg_match ('/^[A-Za-z0-9\s]{1,50}$/', $name)) { if (!empty ($_POST['password'])) { if (preg_match ('/^[A-Za-z0-9]{4,15}$/', $password)) { if (preg_match ('/^[A-Za-z0-9]{4,15}$/', $confirmpassword)) { if (!empty ($_POST['confirmpassword']) && ($_POST['password']) == ($_POST['confirmpassword']) ) { //Sha1 password $password2 = sha1($password); //Database insert $rquery = "INSERT INTO user (uniqueid, email, name, password, rip, lip, dateregistered, lastlogin) VALUES ('0', '$email', '$name', '$password2', '$ip', '$ip', NOW(), NOW())"; if (mysql_query($rquery)) { //Set cookie to help prevent spam setcookie ('registerform', 'registerform', time()+60); //Create unique id $uniqueid = sha1($email); $uquery = "SELECT * FROM user WHERE email = '$email' LIMIT 1"; if ($uresult = mysql_query ($uquery)) { while ($urow = mysql_fetch_array ($uresult)) { $uid = $urow['id']; } } //New unique id = uniqueid+id $uniqueid2 = $uniqueid.$uid; $uquery = "UPDATE user SET uniqueid = '$uniqueid2' WHERE email = '$email' LIMIT 1"; if (mysql_query($uquery)) { echo '<span style="color:#FF0000;font-size:11px">Thanks<br /></span>'; } else { echo '<span style="color:#FF0000;font-size:11px">There was an error registering<br /></span>'; } echo '<span style="color:#FF0000;font-size:11px">You have successfully registered</span>'; } else { echo '<span style="color:#FF0000;font-size:11px">There was an error registering</span>'; } } else { echo '<span style="color:#FF0000;font-size:11px">Your password and confirm password does not match</span>'; } } else { echo '<span style="color:#FF0000;font-size:11px">You have invalid characters in your confirm password</span>'; } } else { echo '<span style="color:#FF0000;font-size:11px">You have invalid characters in your password</span>'; } } else { echo '<span style="color:#FF0000;font-size:11px">Your password is empty</span>'; } } else { echo '<span style="color:#FF0000;font-size:11px">You have invalid characters in your name</span>'; } } else { echo '<span style="color:#FF0000;font-size:11px">Your name is empty</span>'; } } else { echo '<span style="color:#FF0000;font-size:11px">Email duplicate</span>'; } } else { echo '<span style="color:#FF0000;font-size:11px">You have invalid characters in your email</span>'; } } else { echo '<span style="color:#FF0000;font-size:11px">Your email is empty</span>'; } } else { echo '<span style="color:#FF0000;font-size:11px">You must agree to the Terms</span>'; } } else { echo '<span style="color:#FF0000;font-size:11px">You have already registered.</span>'; } }//End isset submit ?>
  11. Nevermind that was pretty stupid. I just made an error page because it keeps looping the redirect.
  12. When I go to index.php which requires header.php I get the below error. The header.php requires the verify_login.php. I don't understand why I'm getting the below error. I get the following error in firefox: The page isn't redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete * This problem can sometimes be caused by disabling or refusing to accept cookies. /functions/verify_login.php <?php function verify_login() { //Check to see if cookie is set if (isset($_COOKIE['id']) && isset($_COOKIE['ip']) && isset($_COOKIE['uniqueid'])){ $cookieid = $_COOKIE['id']; $cookieip = $_COOKIE['ip']; $cookieuniqueid = $_COOKIE['uniqueid']; //Select id and loginip according to cookie uniqueid $query = "SELECT * FROM admin_user WHERE uniqueid = '$cookieuniqueid' LIMIT 1"; if ($result = mysql_query ($query)) { while ($row = mysql_fetch_array ($result)) { $id = $row['id']; $uniqueid = $row['uniqueid']; $ip = $row['ip']; } } } else { header('Location: index.php'); } //Compare cookies with database if ($_COOKIE['id'] != $id && $_COOKIE['ip'] != $ip && $_COOKIE['uniqueid'] != $uniqueid) { //Redirect to index if cookie compare fails header('Location: index.php'); } }//End function ?> header.php <?php require('../connect.php'); require('functions/verify_login.php'); verify_login(); ?> blahblah html goes here index.php <?php require('header.php'); ?> blah <?php require('footer.php'); ?>
  13. You can do something like: "SELECT * FROM table ORDER BY field DESC" or ASC depending if you want ascending or descending
×
×
  • 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.