
TheJoey
Members-
Posts
334 -
Joined
-
Last visited
Never
Everything posted by TheJoey
-
[SOLVED] Trying to create a simple login function
TheJoey replied to TheJoey's topic in PHP Coding Help
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'); } ?> -
<?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
-
where should i apply the trim?
-
so i would make piece $piece = $array['0']['1'];
-
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..
-
second foreach works fine thanks.
-
foreach($_SESSION['items'] as $item){ echo $item['name'] . ', ' . $item['price'] . ', ' . $item['quantity']; } that gives me this Warning: Invalid argument supplied for foreach()
-
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
-
try testing it on localhost first using xampp or something.
-
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.
-
its giving me the error ive programmed it to say. Even if the credit card is valid.
-
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
-
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
-
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'
-
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.
-
Never knew that ! was used to check if isnt. Thanks again cags your always very helpfull
-
[loginsuccessfull] => 1 that showed up with the code snippet you gave me. So i shouldnt use ! in my statement?
-
<?php session_start(); ?> at the top of all my pages
-
put your code in tags makes it easier to read
-
yup its in my html code, because im including the php code.
-
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
-
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'); ?>
-
Sorry i did a little bit of research. It works fine. just wanted to understand it a little more.
-
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();