Jump to content

Ninjakreborn

Members
  • Posts

    3,922
  • Joined

  • Last visited

Everything posted by Ninjakreborn

  1. I tried. It doesn't output anything, I tried modifying it, but still no luck.
  2. Ok, not only does this make sense but this will help me heavily in the future. Based on the fact that if I ever need a percentage I can just adjust this. In FACT, I am going to turn this into a usable function right now, to retrieve the percentage of something. Thank you for that, it will be very helpful later. Another question (might as well not create another post for one). I have looked all over the internet for something to explain about how to hide number's in a string. I am accepting bank account numbers, but the client doesn't want to database it, he wants to FIRST strip out everything from it with * and display only the last 4 (this is no matter how many numbers are present, all are * out except the last 4 numbers, THEN databased. I tried looking for something, and I can't find anything. I tried to play around with my own stuff with no luck, string replace. I could use strlen and put down manually like a function $str = strlen($string); if ($string == 5) { $str = "*" . $str; }elseif ($string == 6) { $str = "**" . $str } but in the end it would end up having to be a long function, and there probably is a much easier way that is not so "long". Does anybody have like a function they credit for credit cards or something where you can pass the value, as well as the amount of letter's you want to show. THen it will automatically obscure (with * or something) all the other characters that are there.
  3. <?php $variable = "random number here"; $percentage = $variable - 10%; // $percentage allways will contain 90% of whatever the monetary value was in variable ?> Is the above correct, and 100% accurate?
  4. This is actually a good habit. When you pass a query into sql then it's required to have that after each command (except the last one). Well in php you are only passing one, so it's a good habit if you ever intend on writing standard sql (like for an install system or something). So I keep it there for habit, it can never cause negative affects. This is not all my code, and it's just the part I am having problems with. As far as this problem, I gave up on using sum. I pulled them all out and did the calculations with PHP.
  5. I never used some before. <?php // this section of php here is made to go ahead and pull out all the deposits // that this specific user has made, add them up, and formulate a total so we can // display it on the page as "total deposits" $deposits = array(); $selectdeposits = "SELECT SUM(amount) FROM transactions WHERE type = 'Deposit' AND userid = '" . $_SESSION['cymember'] . "';"; $totaldeposits = mysql_query($selectdeposits); ?> Basically when I echo total deposits it throws out Invalid Resource ID #9 or something. Based on the many examples I looked at this should work. Originally I had "varchar" as the database type, but tried changing it to "Double." and it's still not working. They are all dollar amounts in the database. 450.00, 400.00, 600.50 obviously it removes the .00 when it's just a flat dollar amount, but it's not adding them up. Any advice.
  6. hehe, we end up always overlooking the most basic things, thanks.
  7. I have the following form (as an example) <?php // this section is for the mailing list. // first check if anything was submitted if (isset($_POST['submit']) && $_POST['submit'] == "Subscribe") { if ($_POST['email'] == "") { // error check email echo "Email Required"; echo "<br />"; $show = "yes"; }else { // subscribe if everything is right $email = mysql_real_escape_string($_POST['email']); $insert = "INSERT INTO mlm_users (email) VALUES ('$email');"; if (mysql_query($insert)) { echo "Subscribed<br />"; }else { echo "Problem subscribing please try again later.<br />"; } $show = "no"; // this will stop the form from showing } }elseif (isset($_POST['submit']) && $_POST['submit'] == "Un-Subscribe") { if ($_POST['email'] == "") { echo "Email Required"; echo "<br />"; $show = "yes"; }else { $email = mysql_real_escape_string($_POST['email']); $insert = "DELETE FROM mlm_users WHERE email = '$email';"; if (mysql_query($insert)) { echo "Un-Subscribed<br />"; }else { echo "Problem subscribing please try again later.<br />"; } $show = "no"; } } if ($show != "no") { ?> <div style="float:right;"><strong><br>Sign up for the inside scoop on special <br>promotions, contests, and exclusive <br>bonuses for our members.</strong><br> <form name="subscription" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <strong>Email:</strong> <input type="email" name="email" value="" /><br /><input type="submit" name="submit" value="Subscribe" /><input type="submit" name="submit" value="Un-Subscribe" /> </form> <font size="1"><strong>Your email address is 100% confidential and will<br>remain that way.</strong></font></div> <?php } ?> Ok, in the end when someone submit's this, they can continue to resubmit it forever. I want a simple method to do this, because I just wanted to do it above the form, very easily. However, I don't want them to be able to re-submit the form over and over and over again and hit the system (in an attack or something). is there a way to easily prevent form re-submittal, or hitting the refresh button over and over again, and still have roughly this same setup.
  8. Ok, I am getting the date like this $date = strtotime(date()); ok, there you have it, a Unix time stamp of the time, date, and everything else. From here, is this the best way to do calculations. Like if I wanted to tell when 48 hours had passed from this date, how do I go about doing that. I know for example if you wanted to add a day, you check on how many "number's" here are in a day and put + that number onto the strength. Can someone tell me some stuff about this, so I am more familiar with dates, before I start all of these calculations.
  9. Hmm, based on what you said and your example I formulated this if (mysql_query($insert)) { $id = mysql_insert_id(); $memberid = $_SESSION['memberid']; $length = strlen($id); switch ($length) { case 1: $modid = "000" . $id; break; case 2: $modid = "00" . $id; break; case 3: $modid = "0" . $id; break; case 4: $modid = $id; break; default: $modid = $id; } $transactionid = $memberid . $modid; echo $transactionid; and it worked perfectly, thanks.
  10. This was like beating a dead horse. Well I finally located the problem. It ended up being what I like to call a "hidden bug". It was something in the admin panel, based off a last change I had made for him, I mistakenly passed an id to a form, but not back to the processor. So when he edited users it gave them all the same password's. I finally tracked that down, and it's working properly now. Thanks for all the advice, it's greatly appreciated, atleast the "proverbial fire" has been putout. After hours of stressing over the wrong area of code. Thanks a lot for the help.
  11. You are accessing a variable that isn't set you have 2 options. 1. Code for notices (meaning code in a way as to prevent notices from happening) 2. Turn them off error_reporting(E_ALL ~ notices); That should turn off notices and only show all the other standard errors. Notices are small issues, and small things. you would be wise to try coding with them, so you can avoid major mistakes, it takes a little extra time but it's worth it later when you learn how to naturally avoid them,and you will have more reliable, more server portable code when everything is done.
  12. echoing out the query also shows this, which is a correct query.
  13. That was a good point, I went ahead and double checked both the query and fetch array using die statements, and nothing. Yes, and what is the strangest is that this just recently happened. He left the system alone for like a few months, and then all of a sudden when he came back to it, it stopped working (his developer did some design work on it), but I reverted it back to an old file and it's still not working. I have checked the following 1. In the admin panel is an area to add clients, delete clients, and edit clients. I tried adding new one's, and editing them. I am sure it's properly creating the information, it's also properly displaying it throughout the admin panel. I even echoed out the values to make sure they were all working. 2. I am sure the name of the table is clients. 3. I am sure the names of those 2 fields are "username, password" 4. I am sure that hte database is operational because it's working for the admin panel 5. I am sure the database information in the admin panel is correct because it's also being used for the admin panel. 6. I am sure that the thing is connected to the file because I am using "require_once()" which returns an error and kills the script when it's not included right. 7. I am sure it's not a database issue (returning syntax errors because of the query, or not being able to connect to the database, or not being able to select the proper database), because the config file is hooked up right, and I personally debugged each one seperately.) It's like the admin system works, but this is broke entirely, and it's the standard login system I normally use for whatever I am doing. 8. I am sure they are sharing the same encryption method (md5)
  14. Yes of course. With php you can do anything with file's, all the way from taking the data from the database, and writing it all into a file. There is anything you can do. You are going to want to 1. Learn Basic PHP file handling 2. Come back here and ask in more detail specifically what you want so we can help point you in the right direction.
  15. When you type the right username and password it say's "Not Logged In Correctly", and if you put in the wrong username and password it says the same thing. Yes session start is there, along with all the database information. I am using require_once so I am sure it's being included, I have also tested with mysql_error and no mysql error's are being returned. Yes, I have fully debugged and tested all the queries. I ended up using echo $select; instead but it's "in nature" the same thing. In the end I tried all of that too. 1. I am 100% the database is connecting 2. I am 100% it's selecting the right database. 3. I am 100% sure the query itself is 100% correct, and the data is passing from the form correctly. As you can see, I have went through a wide array of debugging options, and I am left with absolutely no clue as to why it's not working.
  16. Yes, I used something similar. That old taboo I have read about, that most developer's do but never admit to. Echoing out hello statements in various places to see where it come's at, like hello 1, hello 2, and being able to tell how far the executions are going. I am going to put my code down here above, and show where I KNOW my code is working, and where it's not. I will put MY PERSONAL comments within the old C style commenting using the /* */ method. I also rewrote some of my code for the debugging purposes. <?php require_once("./config.php"); ?> <?php // any custom settings need to be set here. (if they are specific to this page only. if (isset($_POST['submit'])) { /* I am 100% sure it's getting past this point */ $errorhandler = ""; /* It's doing the standard error checking properly */ if ($_POST['username'] == "") { $errorhandler .= "Username was left blank.<br />"; } if ($_POST['password'] == "") { $errorhandler .= "Password was left blank.<br />"; } if ($errorhandler != "") { echo $errorhandler; exit; } if ($errorhandler == "") { /* It's reading this properly (100% sure I tested it )*/ $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string(md5($_POST['password'])); $select = "SELECT * FROM clients WHERE username = '$username' AND password = '$password'"; $query = mysql_query($select); if ($row = mysql_fetch_array($query)) { /* This is where it's not reaching it to. I tried everything I thouroughly checked the admin panel, database and everything. It all looks fine, however this specific login area isn't working properly, and I can't find out why it's not making it to this area. I am 100% sure the username/password are correct. */ $_SESSION['username'] = $_POST['username']; $_SESSION['userid'] = $row['id']; $_SESSION['controller'] = TRUE; header("Location: client.php"); }else { /* This is the part it's picking up instead, the else statement */ echo "Not Logged In Correctly"; } }else { echo "Database Errors"; } } ?> <html> <head> <title>Geo Systems Client System</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php /* The errors properly display, what is happening is the invalid login error is getting returned even though the login information is suppose to be correct */ if (isset($errorhandler) && $errorhandler != "") { echo "<span style=\"color:red\">"; echo $errorhandler; echo "</span>"; } ?> <h1>Client Login</h1> <form name="login" id="login" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <label for="username">Username:</label> <input name="username" id="username" type="text" maxlength="120" /><br /> <label for="password">Password:</label> <input name="password" id="password" type="password" maxlength="120" /><br /> <input name="submit" id="submit" type="submit" value="login" /> </form> </body> </html>
  17. I just tried that and it still didn't work. Also Based on what I have learnt, the extra ; isn't required but it's a good habit if you are use to writing SQL directly instead of using PHPMYADMIN. Those are required when entering SQL directly, so doing them within PHP created queries, just shows that you are closing the query statements When each line is complete. Any one else have any advice as to why this might be giving me problems, it's not working for some reason.
  18. I haven't had a problemw ith a login system for awhile, for some reason this just isn't working. <?php require_once("./config.php"); ?> <?php // any custom settings need to be set here. (if they are specific to this page only. if (isset($_POST['submit'])) { $errorhandler = ""; if ($_POST['username'] == "") { $errorhandler .= "Username was left blank.<br />"; } if ($_POST['password'] == "") { $errorhandler .= "Password was left blank.<br />"; } if ($errorhandler != "") { echo $errorhandler; exit; } if ($errorhandler == "") { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string(md5($_POST['password'])); $select = "SELECT * FROM clients WHERE username = '$username' AND password = '$password';"; $query = mysql_query($select); if ($row = mysql_fetch_array($query)) { echo "yes"; $_SESSION['username'] = $_POST['username']; $_SESSION['controller'] = TRUE; $selectid = "SELECT * FROM clients WHERE username = '$username' AND password = '$password';"; $queryid = mysql_query($selectid); if ($rowid = mysql_fetch_array($queryid)) { $_SESSION['userid'] = $rowid['id']; } header("Location: client.php"); }else { echo "Not Logged In Correctly"; } }else { echo "Database Errors"; } } ?> <html> <head> <title>$#$####</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php if (isset($errorhandler) && $errorhandler != "") { echo "<span style=\"color:red\">"; echo $errorhandler; echo "</span>"; } ?> <h1>Client Login</h1> <form name="login" id="login" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <label for="username">Username:</label> <input name="username" id="username" type="text" maxlength="120" /><br /> <label for="password">Password:</label> <input name="password" id="password" type="password" maxlength="120" /><br /> <input name="submit" id="submit" type="submit" value="login" /> </form> </body> </html> I have done all standard debugging. There is an admin panel where the stuff is created, I checked that, as well as the database itself. They both all look in order. I tested the variables, they are definitely getting passed, I also echoed the query, it seems to be like it should. IN ht eend I have tried everything I can think of and it continues to say "login information incorrect". Any advice will be greatly appreciated.
  19. Ok, let me cut the question down a little so it's not as generic now that I know a little more of what I am needing to create. I have a specific member id. I have that, it's fine, to get it proper they'll be 2 halves to the id to make it a full id. $id = $_SESSION['memberid'] . "second half"; The second half is what I am going to have problems with. Basically I need to have the member id, followed by a 4 digit number. This number is going to be all 0000 except for the id that was entered into the database. I am getting the id into a variable called id using mysql_insert_id directly after the query. That is fine, so now I have everything I need except how to do the calculations to make this proper. 1. I have the member id in a session. 2. I have the id for the entry into the database put into a variable. Now I need to get that id of the database entry to basically add however many zero's "in front" of it to make it 4 digits. If the number is 1 it needs to end up being 0001, if it's 2 it needs to end up being 0002. If the number is 20 it needs to be 0020. If it ends up being 200 it needs to be 0200. If the number is 2000 it need's to just be 2000. It needs to always be 4 digits in length, and whatever digits it does not have need to be appended at the beginning in the form of zero's. Any advice on how to do this properly, thanks.
  20. Originally I began accepting weird formats for dates. Now I always take whatever format it is and convert it to a unix time stamp and put it in the database. This was the original way that was suggested. I found this very helpful based on multiple facts (I end up needing to change the format a lot and it's easy when it's in a time stamps, sometimes I need to do calculations and this format helps as well). Well right now I am about to have some major calculations for a project. These are going to be unlike any calculations I have ever done before, and it's going to take a lot of brain power to complete. However I wanted to get the best environment to do these in. I need to do stuff like take a certain time, and figure how long it'll be until different amounts of hours have passed. For one I need to do something after 48 hours pass, for another I need to do something after 20 hours have passed (just some examples). Right now I normally accept 04/07/2007 as the date, then I use strtotime on this. From what I have here, can I use other date functions to still pull the time, and everything from the original date they entered. Will I be able to get the time, and the hour, or how does this work inside PHP. For example somebody puts in today's date, and I run it through str to time. 48 hours (2 days) from the time they entered it I need to run some calculations to change the status on whatever the payment was. This is all fine, but now it leaves me with a question. Since the original user only put in a date, it has no way of attributing a time to it. Does it automatically start it at a specific time, or what? I need to be able to specifically get a general idea before I start performing calculations on it, thanks.
  21. There was some kind of misunderstanding, there was a specific type of xml request object tutorial. I can't explain what I wanted. Red you are off a little on this one. This wasn't for a paying client, it was for a friend, I had unlimited time and it was just something I was messing around with on the side. I work my projects, but I do a little bit of studying, and getting into new things on the side. I understand that it sounds like I am seeking advice and dropping it,but I am not. No I am not against using MooGoo tool's, or any of the other's that I have seen. However I don't personally want to spend years using a good third party library of javasript, and never go back and learn how to do the requests myself. The type of tutorial I was requested was different than either of those you showed me. What I am looking for is a different explanation, I can't explain it better than that. I am going to have to find that original book, there is a specific way I want to learn how to do them, where they use three seperate functions, and there's a function for creating the object that's suppose to work in ANY browser. The original one I saw had about 35 lines of code, just preparing the object, I wanted to see that again, I just have to find the book I was reading with that example.
  22. I found out what it was, after some digging it's a device that a user can use on there computer. It hides your information, and uses (random generated word from a random language) (name of the company) (random lettering afterwards) and it re-auto-generates that every time to keep hiding where the host is from, it took me 4 hours to piece that together that day just out of curiosity.
  23. Yes, in this situation the reassuring thing to me is I NEVER look at my access logs. Now it's got me wondering what visits ...
  24. Yes, I came up with something and it works perfectly. I created <script type="text/javascript"> <!-- function delayer(){ window.location = "cymember.php"; } //--> </script> I also can modify that, to put an argument there for the url if I need to change that around. From there I use echo "Updated Successfully.<br />"; echo "Redirecting...."; ?> <script type="text/javascript"> setTimeout('delayer()', 3500) </script> and so far it seems to be working flawlessly. Thanks for all the feedback, if he ends up liking the way this works, I think I will use this in my future projects as well. More user friendly that way anyway.
  25. http://www.tizag.com/javascriptT/javascriptredirect.php Ok, I have the Java script Bible, which has a lot. is there an on line directory of in-build Java Script functions, that explain the different one's, because I wasn't even aware that the setTimeout() function existed. Again, this post has veered into Java Script, instead of PHP. I originally was thinking some way with output buffering to delay the location header or something, thanks for the feedback.
×
×
  • 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.