Jump to content

TheJoey

Members
  • Posts

    334
  • Joined

  • Last visited

    Never

Everything posted by TheJoey

  1. Should i remove the $fp = $fp = fopen("registrationinfo/info.txt","a"); ?? well with the modified code i still didnt get anything. <?php session_start(); $usernamematch = $_POST['username']; $passwordmatch = $_POST['password']; $fp = fopen("registrationinfo/info.txt","a"); $fileData = fread($fp,filesize("registrationinfo/info.txt")); $array = explode(':', $fileData); $username = trim($array[0]); //user-name $password = trim($array[1]); //password if ($username == $usernamematch & $password == $passwordmatch) { $_SESSION['loginsuccessfull'] = true; header('location indexsuccessfull.php'); } else { header('location wronginfo.php'); } ?>
  2. <?php session_start(); $usernamematch = $_POST['username']; $passwordmatch = $_POST['password']; $fp = fopen("registrationinfo/info.txt","a"); $array = explode(':', $fp); $username = trim($array[0]); //user-name $password = trim($array[2]); //password if ($username == $usernamematch && $password == $passwordmatch) { $_SESSION['loginsuccessfull'] = true; header('location indexsuccessfull.php'); } else { header('location wronginfo.php'); } ?> but at the moment its doing nothing just a blank page. im not sure how to work with txt files this way. any help is much appricatied
  3. where should i apply the trim?
  4. so i would make piece $piece = $array['0']['1'];
  5. hello i have a text file which has information seperated by | so its text1 | text2 | text3 | text4| how do i extract text1 & text2 so i can use it in a login..
  6. second foreach works fine thanks.
  7. foreach($_SESSION['items'] as $item){ echo $item['name'] . ', ' . $item['price'] . ', ' . $item['quantity']; } that gives me this Warning: Invalid argument supplied for foreach()
  8. foreach($_SESSION['itemprice'] as $item_price) { echo '$'.$item_price."\r\n"; } echo "\r\n"; foreach($_SESSION['itemqty'] as $itemqty) { echo '#'.$itemqty."\r\n"; } echo "\r\n"; foreach($_SESSION['itemname'] as $itemname) { echo 'Name:'.$itemname."\r\n"; } how would i make it display itemname : item_price : itemqty when i tried i just got a bunch of errors, i even tried joining the foreach's
  9. try testing it on localhost first using xampp or something.
  10. if (!is_numeric($cc) && !luhn_check($cc)) $errorCC = true; else $errorCC = false; this checks the algorithmn fine just doesnt check for numeric if (!is_numeric($cc) || !luhn_check($cc)) $errorCC = true; else $errorCC = false; this works well with numeric but doesnt use the luhn check well.. Lol i dont know wat to do.
  11. its giving me the error ive programmed it to say. Even if the credit card is valid.
  12. luhn check is a credit card functionality it works fine, but its not giving me errors for letters and such. <?php /* Luhn algorithm number checker - (c) 2005-2008 - planzero.org * * This code has been released into the public domain, however please * * give credit to the original author where possible. */ function luhn_check($number) { // Strip any non-digits (useful for credit card numbers with spaces and hyphens) $number=preg_replace('/\D/', '', $number); // Set the string length and parity $number_length=strlen($number); $parity=$number_length % 2; // Loop through each digit and do the maths $total=0; for ($i=0; $i<$number_length; $i++) { $digit=$number[$i]; // Multiply alternate digits by two if ($i % 2 == $parity) { $digit*=2; // If the sum is two digits, add them together (in effect) if ($digit > 9) { $digit-=9; } } // Total up the digits $total+=$digit; } // If the total mod 10 equals 0, the number is valid return ($total % 10 == 0) ? TRUE : FALSE; } ?> if (is_numeric($cc) && luhn_check($cc)) $error = false; else $error = true; seems to be giving me error regardless
  13. hey i need to rewrite this if (luhn_check($number)) to include is_numeric though im having trouble when i use it as if (luhn_check(is_numeric($cc))) im guessing it cant be done that way, but i really need to implement it similar
  14. The saving of the session works fine but it doesnt seem to get the information i want Array ( [login] => 1 ( [item] => item [item1] => item1 [item2] => item2 ) [itemqty] => Array ( [item] => 16 [item1] => 22 [item2] => 23 ) [itemprice] => Array ( [item] => 150 [item1] => 60 [item2] => 40 ) ) thats how the array looks. how do i extract all of the itemprice array because when i do it just echos 'array'
  15. Just wondering if there is a way to parse information stored in session and put it into a .txt file. echo '<pre>'; print_r($_SESSION); echo '</pre>'; i get this information about my session Array ( [logins] => 1 [item] => item1 [price] => 70 [itemname] => Array ( [item1] => item1 ) [itemqty] => Array ( [item2] => 3 ) [itemprice] => Array ( [item1] => 70 ) [qty] => 3 ) just wondering if this can be done and how i would go about doing so.
  16. Never knew that ! was used to check if isnt. Thanks again cags your always very helpfull
  17. [loginsuccessfull] => 1 that showed up with the code snippet you gave me. So i shouldnt use ! in my statement?
  18. <?php session_start(); ?> at the top of all my pages
  19. put your code in tags makes it easier to read
  20. yup its in my html code, because im including the php code.
  21. Hey im trying to make a bit of script that will hide links from users that arent logged in. <?php if(!$_SESSION["loginsuccessfull"]) { echo '<h2><a href="order.php">Proceed to Order Page</a></h2> <h2><a href="products.php">Continue Shopping</a></h2> <h2><a href="resetcart.php">New Cart</a></h2> <h2><a href="ordertest.php">Proceed to Order Page session</a></h2>'; } else { echo ' <h2><a href="login.php">Login to view Order Page</a></h2> <h2><a href="products.php">Continue Shopping</a></h2> <h2><a href="resetcart.php">New Cart</a></h2> '; } ?> but even if i have logged in it still only displays Login to view Order Page Continue Shopping New Cart
  22. Redirecting You Now Warning: Cannot modify header information - headers already sent on line 48 im getting this error for this code its included in the body of my html code. <?php unset($_SESSION['loginsuccessfull']); echo 'Redirecting You Now'; header('location : ../../index.php'); ?>
  23. Sorry i did a little bit of research. It works fine. just wanted to understand it a little more.
  24. well yer.. it destroys the session but im not sure im declaring it right. Do i have to use <? session_start(); isset($_SESSION['login']); ?> or just session_start();
×
×
  • 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.