Jump to content

bobleny

Members
  • Posts

    429
  • Joined

  • Last visited

    Never

Everything posted by bobleny

  1. Thats what I suspected... I was hoping that some how the XML would make the Javascript a server side language... I don't like to use any Javascript, because if the browser isn't capable of handling it then you run into problems. I do use it for things that wont be effected if Javascript is disabled or not supported. I also like to allow it as an OPTION rather than a requirement. So I might have a Javascript clock that gives up to the second time, or they click PHP clock, and then they get the time each time the page is reloaded.... Thanks for the response, I only wish you had better news. Bye.
  2. Just a simple question: Can AJAX run in a browser that doesn't support Javascript? Another simple question: XML Compatible with all browsers, new and old?
  3. Thank! It works now. I set it to 300 images, and it only took 29 seconds. It would take at least an hour otherwise! Thanks for all of your help!
  4. I tried it again, but this time I use a larger number. getimagesize() worked fopen() didn't work so well... I will use getimagesize(). Is there a way to say, if getimagesize() fails 4 times consecutively, stop? For example, here is what I actually have: for($r = 1; $r <= $c; $r++) { $i = str_pad($r, $digits, '0', STR_PAD_LEFT); if (getimagesize($before.$i.$after)) { echo "<img src='".$before.$i.$after."'><br />\r\n"; } } Say there are actually only 10 images. Say for some reason $c = 300. The 10 images will work, but the rest will fail because there are only 10 images, right? How do I tell the for loop to stop looping after getimagesize() fails 4 times in a row?
  5. file_exists() doesn't seem to work at all.... If you list images sometimes you get a little tiny square that looks like it's been ripped in half. That could be because the file doesn't exist or because the file is broken. Either way, I want to keep that from being displayed...
  6. neel_basu, Thank you for the reply. Both "getimagesize()" and "fopen()" seem to work the same. Is there a different way, or should I look into Javascript? --------------------------------- Also, neel_basu, if you are to criticize someones sig, you might consider reading it... No where in my sig does it say anything about PHPBB... :/
  7. ToonMariner, When I use that, I get this error: Fatal error: Call to undefined function isfile() ------------------------------ neel_basu, Uh, for the record, I hate PHPBB...
  8. Is there a way to say, if an image is broken, don't show it? For example, basically, it looks much like this: echo "<img src='snow".$i.".jpg'><br />\r\n"; If for some reason the image is broken, I don't want it to echo the link. This works, but it is really slow! if (fopen("snow".$i.".jpg", 'r')) { echo "<img src='snow".$i.".jpg'><br />\r\n"; }
  9. No, thank, john010117! He got it to work... I'm not real good with MySQL I must admit... I can usually solve my problems...
  10. john010117, Thanks, but we've already tried that. But there is no harm in trying it again! Go for it ritchie!
  11. Try this: //Insert new user $username = $_POST['username']; $email = $_POST['email']; $query = "INSERT INTO members ('username', 'password', 'email') VALUES ($username,$password,$email)"; echo $query; die(); mysql_query($query) or die(mysql_error()); //Close mysql mysql_close();
  12. God! Try this: //Insert new user $username = $_POST['username']; $email = $_POST['email']; $query = mysql_query("INSERT INTO members ('username', 'password', 'email') VALUES ('$username', '$password', '$email')") or die(mysql_error()); //Close mysql mysql_close();
  13. Ok, something happened to my script change when I posted it Try this: //Insert new user $username = $_POST['username']; $email = $_POST['email']; $query = mysql_query("INSERT INTO members ('username', 'password', 'email') VALUES ('" . $username . "', '" . $password . "', '" . $email . "')"); echo "<br /><br />" . $query . "<br /><br />"; die(); //Close mysql mysql_close(); Try that. That is what you should have tried but I think it got messed up some how....
  14. Thats what I thought.... Try this: //Insert new user $username = $_POST['username']; $email = $_POST['email']; $query = mysql_query("INSERT INTO members ('username', 'password', 'email') VALUES ('" . $username . "', '" . $password . "', '" . $email . "')"); echo "<br /><br />" . $query . "<br /><br />"; die(); //Close mysql mysql_close();
  15. OK, use this: //Insert new user $username = $_POST['username']; $email = $_POST['email']; $query = "INSERT INTO members ('username', 'password', 'email') VALUES ('" . $username . "', '" . $password . "', '" . $email . "')" echo $query; die(); mysql_query($query) or die(mysql_error()); //Close mysql mysql_close();
  16. Write this: echo $query die(); Directly below this line: $query = mysql_query("INSERT INTO members ('username', 'password', 'email') VALUES ('" . $username . "', '" . $password . "', '" . $email . "')") or die(mysql_error()); Tell me what it prints.
  17. Bye now you have to be wondering how I ever get anything done! Lets just say I have NEVER EVER had this many problems with a script! This is a bit of advice for you. Never write a whole script like this before testing it. When I script, I use my local server and test each part. It allows you to solve tiny problems along the way. This prevents all the tiny script errors from making you redo the entire script over and over again.
  18. Well, that is self explanatory. It means your where unable to connect to the database because your not authorized. This normally means that your username or password is incorrect. In this case, it is my fault once again! use this: <?php //Start the session session_start(); //Database Information //Username? $database_username = "root"; //Your password? $database_password = ""; //The name of the database you are trying to connect to $database_database = "main"; //Did the user enter a username? if (strlen($_POST['username']) < 4) { //There username contains less than 4 characters //Set a session variable so that you can tell the user how they screwed up $_SESSION['short_username'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //Did the user enter a password? if (strlen($_POST['password']) < 4) { //There password contains less than 4 characters //Set a session variable so that you can tell the user how they screwed up $_SESSION['short_password'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //Did the user enter a email address? if (strlen($_POST['email']) < { //There email contains less than 4 characters //Set a session variable so that you can tell the user how they screwed up $_SESSION['bad_email'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //Make sure they aren't trying to hack you if (preg_match("/[^a-zA-Z0-9_-]/", $_POST['username'])) { //Their username contains invalid characters //They me be trying to hack you... //Set a session variable so that you can tell the user how they screwed up $_SESSION['bad_username'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //Make sure they aren't trying to hack you if (preg_match("/[^a-zA-Z0-9]/", $_POST['password'])) { //Their password contains invalid characters //They me be trying to hack you... //Set a session variable so that you can tell the user how they screwed up $_SESSION['bad_password'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //Make sure they aren't trying to hack you if (preg_match("/[^a-zA-Z0-9_.@-]/", $_POST['email'])) { //Their email contains invalid characters //They me be trying to hack you... //Set a session variable so that you can tell the user how they screwed up $_SESSION['bad_email'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //For added security, MD5 their passwords before you compare them $md5_password = md5($_POST['password']); $md5_varpassword = md5($_POST['varpassword']); //For the users benefit, make sure their passwords match if ($md5_password != $md5_varpassword) { //There passwords did not match //Set a session variable so that you can tell the user how they screwed up $_SESSION['match_password'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //If something went wrong, send them back to fix their mistakes if ($pass == TRUE) { //They failed the exam //For some reason they have failed or check system //You will need to send the back to fix the problem before we continue echo "<meta http-equiv=\"refresh\" content=\"1;url=signup.php\">"; //I like to kill the script at this point. die(); } else { //They have entered all the required information //Their username, password, and email are acceptable //For the users protection, you should always encrypt their passwords $password = md5($_POST['password']); //You now have all their info, you may put them into the database //Connect to the database $connect = mysql_connect('localhost',$database_username,$database_password) or die(mysql_error()); //Select your database mysql_select_db($database_database) or die(mysql_error()); //Insert new user $username = $_POST['username']; $email = $_POST['email']; $query = mysql_query("INSERT INTO members ('username', 'password', 'email') VALUES ('" . $username . "', '" . $password . "', '" . $email . "')") or die(mysql_error()); //Close mysql mysql_close(); //They are now signed up //Tell them that they are now signed up echo "Congratulations, you are now signed up!"; //Send them back to the home page echo "<meta http-equiv=\"refresh\" content=\"6;url=index.php\">"; //Offer an optional link in case the transfer doesn't work echo "<a href=\"index.php\">If you are not transfered in 10 seconds, click here</a>"; } ?> I forgot to update the variables....
  19. Well, then do you know what that tells us? It tells us that I am a dumb...... Anyways, I found the problem.... The die() in the if statement tells us that for some reason $pass = FALSE. The problem is, none of our checks told it to be false. Where did I go wrong? I forgot that a variable that is not set, is false. Because of that, the value of $pass in always false until other wise stated. The fix is simple, reverse it... Replace your check.php with this: <?php //Start the session session_start(); //Database Information //Username? $database_username = "root"; //Your password? $database_password = ""; //The name of the database you are trying to connect to $database_database = "main"; //Did the user enter a username? if (strlen($_POST['username']) < 4) { //There username contains less than 4 characters //Set a session variable so that you can tell the user how they screwed up $_SESSION['short_username'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //Did the user enter a password? if (strlen($_POST['password']) < 4) { //There password contains less than 4 characters //Set a session variable so that you can tell the user how they screwed up $_SESSION['short_password'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //Did the user enter a email address? if (strlen($_POST['email']) < { //There email contains less than 4 characters //Set a session variable so that you can tell the user how they screwed up $_SESSION['bad_email'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //Make sure they aren't trying to hack you if (preg_match("/[^a-zA-Z0-9_-]/", $_POST['username'])) { //Their username contains invalid characters //They me be trying to hack you... //Set a session variable so that you can tell the user how they screwed up $_SESSION['bad_username'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //Make sure they aren't trying to hack you if (preg_match("/[^a-zA-Z0-9]/", $_POST['password'])) { //Their password contains invalid characters //They me be trying to hack you... //Set a session variable so that you can tell the user how they screwed up $_SESSION['bad_password'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //Make sure they aren't trying to hack you if (preg_match("/[^a-zA-Z0-9_.@-]/", $_POST['email'])) { //Their email contains invalid characters //They me be trying to hack you... //Set a session variable so that you can tell the user how they screwed up $_SESSION['bad_email'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //For added security, MD5 their passwords before you compare them $md5_password = md5($_POST['password']); $md5_varpassword = md5($_POST['varpassword']); //For the users benefit, make sure their passwords match if ($md5_password != $md5_varpassword) { //There passwords did not match //Set a session variable so that you can tell the user how they screwed up $_SESSION['match_password'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //If something went wrong, send them back to fix their mistakes if ($pass == TRUE) { //They failed the exam //For some reason they have failed or check system //You will need to send the back to fix the problem before we continue echo "<meta http-equiv=\"refresh\" content=\"1;url=signup.php\">"; //I like to kill the script at this point. die(); } else { //They have entered all the required information //Their username, password, and email are acceptable //For the users protection, you should always encrypt their passwords $password = md5($_POST['password']); //You now have all their info, you may put them into the database //Connect to the database $connect = mysql_connect('localhost',$username,$password) or die(mysql_error()); //Select your database mysql_select_db($database) or die(mysql_error()); //Insert new user $username = $_POST['username']; $email = $_POST['email']; $query = mysql_query("INSERT INTO members ('username', 'password', 'email') VALUES ('" . $username . "', '" . $password . "', '" . $email . "')") or die(mysql_error()); //Close mysql mysql_close(); //They are now signed up //Tell them that they are now signed up echo "Congratulations, you are now signed up!"; //Send them back to the home page echo "<meta http-equiv=\"refresh\" content=\"6;url=index.php\">"; //Offer an optional link in case the transfer doesn't work echo "<a href=\"index.php\">If you are not transfered in 10 seconds, click here</a>"; } ?>
  20. Sorry for the time, I didn't see you post. Same thing as what? Did it send you back to signup.php? Or does it stay at check.php?
  21. Right, the die() function tells php to stop parsing the information. By telling it to stop at that point, it tells me that everything above that point is not causing the problem. Now, move the die() function that you just entered to right above this line: //They failed the exam so it would be: //If something went wrong, send them back to fix their mistakes if ($pass == FALSE) { die(); //They failed the exam //For some reason they have failed or check system //You will need to send the back to fix the problem before we continue echo "<meta http-equiv=\"refresh\" content=\"1;url=signup.php\">"; //I like to kill the script at this point. die(); } Tell me what it does...
  22. Ok... Add this line: die(); Right before this line: //If something went wrong, send them back to fix their mistakes Then run the script again with: Username: ritchie password: ritchie varpassword: ritchie email: ritchie@gunz.net Now what happens?
  23. Odd.... What happens when you try this? Username: ritchie password: ritchie varpassword: ritchie email: ritchie@gunz.net
×
×
  • 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.