Jump to content

TheJoey

Members
  • Posts

    334
  • Joined

  • Last visited

    Never

Everything posted by TheJoey

  1. Trying to correct my code the first problem i ran into was Warning: file_get_contents() expects parameter 1 to be string, when replacing fputs. The other thing i dont understand is, When you say use $_SESSION? all i know is that when i do the saving part, it seems to work well and encrypts the information i need. it just displaying it that im having trouble with
  2. hi im currenlty trying to read from a file that saves all my session data into a txt file. Only problem is when i read from it i only get Resource id #3 <?php $sessionfile = fopen("sessionfile.txt", "w"); fputs($sessionfile, session_encode( ) ); fclose($sessionfile) ?> <?php session_start(); ?> <?php $sessionfile = fopen("sessionfile.txt", "r"); session_decode(fputs($sessionfile, 4096) ); fclose($sessionfile); ?> <html> <body> <?php echo $sessionfile; ?> </body> </html>
  3. im using this form of luhns algorithm <?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; } ?> Only problem is when im using it doesnt seem to be validating the input. How about would you guys go about trying to use it? if the text box were trying to use has these values name=$creditvalue
  4. it fixed the syntax although it doesnt seem to be validating
  5. hi im trying to use credit card validation Luhn algorithm. im storing it in a seperate php and including it on my needed page <?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; } ?> im trying to use it like this but its not working. if ($errorluhn) $errorluhn = "luhn validation"; $luhn = isset($_POST['luhn']) ? trim($_POST['luhn']) : ''; if (luhn_check($luhn) $errorluhn = true; if (luhn_check($luhn) $errorluhn = true; that line is the acutally line where im getting trouble with
  6. <html> <body> <?php if (isset($_POST['submit'])) { if($_SESSION['item']==$_POST['h1']) { $_SESSION['qty'] = $_SESSION['qty'] + 1; } else { $_SESSION['item'] = $_POST['h1']; $_SESSION['price']= $_POST['h2']; } $_SESSION['itemprice'][$_SESSION['item']] = $_SESSION['price']; $_SESSION['itemqty'][$_SESSION['item']] = $_SESSION['qty']; $_SESSION['itemname'][$_SESSION['item']] = $_SESSION['item']; } ?> <table> <tr> <td> </td> <td>ITEM info here</td></tr> <tr><td><form action="cartpost.php" method="post"><input type="submit" name="submit" value="ADDING"/><input type="hidden" name="value" value="itemid" /><input type="hidden" name="value1" value="7000"/></form> </td></tr> </table> <a href="cart.php">View your cart</a> </body> </html> this just outputs into the minicart <?php echo "The shopping cart looks as follows:--"; if(isset($_POST['submit'])) { $itemname = $_POST['value']; unset($_SESSION['itemqty'][$itemname]); unset($_SESSION['itemprice'][$itemname]); unset($_SESSION['itemname'][$itemname]); } echo "<br/><br/>"; echo "<table border='1'>"; echo "<tr><th>itemname</th><th>Qty</th><th>Price</th></tr>"; if (isset($_SESSION['itemname'])) { foreach($_SESSION['itemname'] as $key=>$value) { echo '<tr><td>'.$_SESSION['itemname'][$key].'</td><td>'; $_SESSION["itemqty"][$key]; echo $_SESSION["itemqty"][$key]; echo '</td><td>'.$_SESSION['itemprice'][$key].'</td><td><form id="f1" method="post" name="f1"><input type="submit" name="submit" value = "delete"><input type="hidden" name="value" value='.$key.'></td></tr>'; } } echo "</table>"; ?>
  7. When im adding to my shopping cart. It is being display as an empty value, inside quantity when its really a 1. So then the incremental is then out of wack the next time i add a item. so if instead of it being display as 2 it is being displayed as 1. Because of the fact that its starting off as NULL.
  8. ahh sorry if i didnt explain myself well guys. i tend to do that sometimes. I have a shopping cart and when i add a item it displays item name : (Nothing here as 1) : price then when i click add again it adds it as item name : 1 : price where i want 1 to be a incremental
  9. well im just echoing a qty that ive stored ina session <?php echo $_SESSION["qty"][$key]; ?> just want to know if i can make it always echo 1 insted of 0
  10. Hey guys i need a way to set a default value of a a product in my shopping cart to 1 at the moment its 0.
  11. I have a shopping cart, and everytime i go to add the same item to a cart it adds +1 to quanity the only problem is. I dont know how to refresh this so that session is only set for say 1 hour then reset or something similar to that.
  12. that just displays them after each other is there a way where i can join both first lines?
  13. ive got this script which shows the two files joined. althought it displays it wrong. text dsf sdf sd fs df sd f sdf s df sd text1 mo||67||joe||joe joe||67|||| this is the code that joins them both <?php $joined = file_get_contents('users.txt') . file_get_contents('data.txt'). "\r\n"; echo $joined; ?> and it is being displayed this way dsf sdf sd fs df sd f sdf s df sdmo||67||joe||joe joe||67||||
  14. thorpe only problem is @:@ @:4 $:5mo||67||joe||joe joe||67|||| it displays them all on the same line
  15. thank you bricktop another question for you, i thought i could ask you insted of making a topic How would i join two .txt files and display the output could this be done with join?
  16. yeh like insted of showing the full link have something like urlhere.com/index?(1,2,3,4,5,6 all as diferent pages insted of showing urlhere.com/registration.php
  17. How do i make my links show up as urlhere.php?index or urlhere.php?login etc
  18. it seems to always give me the success.php page even if password is wrong
  19. Parse error: syntax error, unexpected T_IF in php.php on line 5 im getting that
  20. hey im trying to create a simple login where the username and admin are fixed and i was hopeing to do it similar to this <?php session_start(); $name = $_POST['username']; $pass = $_POST['password']; if $name = 'admin' && $pass = 'admin' { $_SESSION['success'] = true; header("location: success.php"); } else { header("location: nsuccess.php"); } ?> cant seem to get this to work.
  21. this worked a charm sorry guys its not my code, its for a friend.
  22. well im using classes for my shoppingcart, and just looking for a way to hand the total cost to the next page.
×
×
  • 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.