Jump to content

pneudralics

Members
  • Posts

    241
  • Joined

  • Last visited

    Never

Everything posted by pneudralics

  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
  14. I use the below to verify user login. I first check the cookie for the id, ip and a unique id. If it's set then I move on to verifying that they all belong together. I usually copy and paste everything on a page that needs verification and I just edit the "we are good...." part. Login verification <?php //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']; require('header.php'); //Select id and loginip according to cookie uniqueid $query = "SELECT * FROM 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']; } } //Compare cookie ip and id with query loginip and id --- if cookies match database then we allow if ($_COOKIE['id'] == $id && $_COOKIE['ip'] == $ip && $_COOKIE['uniqueid'] == $uniqueid) { ?> we are good.... <?php require('footer.php'); //End cookie compare } //Redirect to index if cookie compare fails else { header('Location: index.php'); } //End cookie set } //Redirect to index if cookie is not set else { header('Location: index.php'); } ?> I was wondering if there was a way for me to just do something like: <?php require('verify.php'); //If not logged in user wont see the below.. ?> Login user sees this
  15. A basic login will work something like: - User clicks login submit - php form checks and validate username and password - php sets cookies for sessions and redirects user to a page - on the redirected page it checks the cookies to ensure everything is set - then validate the credentials of the cookies - if everything validates good the page shows to the member
  16. I usually do something like this $description = mysql_real_escape_string(htmlentities(strip_tags(trim($_POST['description']))));
  17. Yes each time the page is loaded, the codes are reloaded.
  18. I want to look for id 9. I know how to check the database with WHERE = '9', but what do I do to make it return true or false when it finds or not find 9? I pretty much want to check the database field id for a specific number. Not sure if the above is the way to go. I want php to tell me they found 9 or not.
  19. Try something like this: onclick="window.location=index.php?Page=Profile&PROFILE_ID=<?php echo $USER_ID ?>">
  20. I wasn't sure where to put this thread. I'm trying to get a javascript src to display a php page. The problem is when I use php on the page like test2.php below it doesn't display anything. If I use plain text it works. What can I do to let it display php echos? test.php <script type="text/javascript" src="http://localhost/test.php"></script> test2.php //The below works var test = ''; test = "<div style=\"color:#FF0000;\">yay</div>"; document.write(test); //The below does not work var test = ''; test = "<div style=\"color:#FF0000;\"><?php echo 'blahblah'; ?></div>"; document.write(test);
  21. Example... http://affiliatemarketer.info/ That website has a small javascript on the right side to display their latest blog postings. Someone can take that javascript and paste it on their website then it'll show what's on affiliatemarketer.info's blog posting. I'm wondering how this is made and just need some directions on where to go. Thanks
×
×
  • 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.