Jump to content

livepjam

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

livepjam's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [url=http://www.phpfreaks.com/forums/index.php/topic,109786.0.html]http://www.phpfreaks.com/forums/index.php/topic,109786.0.html[/url] You may want to check out this thread.
  2. Okay, yeah I understand that you would say $_POST['form_fieldname']; to get the data. My issue is this: I am trying to output this page dynamically by using the same textbox, but by giving it a different name each time such as this: [code]NAME="<?php echo $_SESSION['cart'][$i]; ?>[/code] I am doing the output in the while loop: [code]while (!empty ($_SESSION['cart'][$i])): ?> <tr><td><INPUT TYPE="text" NAME="<?php echo $_SESSION['cart'][$i]; ?> SIZE="1" value="<?php echo $_SESSION['qty'][$i]; ?>"></td> <td><a href="game.php?id=<?php echo $_SESSION['cart'][$i]; ?>"><?php echo $_SESSION['cart'][$i]; ?></a></td> <td><?php echo $_SESSION['price'][$i]; ?> </td></tr> <?php $totalprice+=$_SESSION['price'][$i] * $_SESSION['qty'][$i]; $i++; endwhile;[/code] Because I am using a PHP array as the name of each textbox, I am having trouble accessing the data using $_POST. [code]<tr><td><INPUT TYPE="text" NAME="Game 1" SIZE="1" value="1"></td> <td><a href="game.php?id=Game 1">Game 1</a></td> <td>49.99 </td></tr> <tr><td><INPUT TYPE="text" NAME="Game 2" SIZE="1" value="1"></td> <td><a href="game.php?id=Game 2">Game 2</a></td> <td>55.99 </td></tr>[/code] If I had two items in my cart, the resulting HTML is above. Because I am using an array to store the name of the game and assigning the text box the name of the game, how can I access the Post data using the name of the array? Does that make sense?  ???
  3. Nevermind - had another question here, but I want to try something first.
  4. Can someone help me with this? Am I going about this incorrectly? Thanks.
  5. You might want to take a look at the new google checkout: [url=http://checkout.google.com]checkout.google.com[/url]
  6. livepjam

    false

    It is empty, but it still holds the value false. [code]<?php $blah = false; if ($blah == false) echo "It is empty"; ?>[/code] If you do that, it outputs the echo.
  7. livepjam

    false

    Eh, I'm not sure now... I tried the following code and it output the text: [code]<?php $blah = false; if (empty($blah)) echo "It is empty"; ?>[/code] I guess that would mean the variable is empty.
  8. livepjam

    false

    I believe it would truly make it a boolean, i.e. false.
  9. [quote]please md5 the passwords so they won't get stolen so easily.[/quote] Isn't SHA1 more secure?
  10. [code]<INPUT TYPE="text" NAME="name=<?php echo $_SESSION['cart'][$i]; ?>" SIZE="1" value="<?php echo $_SESSION['qty'][$i]; ?>[/code] I am trying to build a shopping cart and the code above is the QTY box. This is sitting in a while loop so it outputs for each game in the cart. Lets say I am using a Submit button to POST the update in QTY, how would I access the data above using $_POST? Something like $_POST[$_SESSION['cart']] ? Basically, the text box is going to be equal to the name of the game. So, after I access this data I'm going to use the name from the box to update the quantity in the array that it is being stored in. Here is the full code in case: [code] cart.php: <?php ini_set( "session.bug_compat_warn", "off" ); require_once('session.php'); require_once('output_page.php'); require_once('nav.php'); ?> <div id="cart"> <table> <?php include "dbgamesconn.php"; $name = $_GET['id']; if (!empty($_GET['id'])) { $query ="SELECT * FROM games WHERE title='$name'"; $result = mysql_query($query); $upc = mysql_result($result,0,"upc"); $title = mysql_result($result,0,"title"); $platform = mysql_result($result,0,"platform"); $desc1 = mysql_result($result,0,"desc1"); $desc2 = mysql_result($result,0,"desc2"); $pricemem = mysql_result($result,0,"pricemem"); $pricenon = mysql_result($result,0,"pricenon"); $image = mysql_result($result,0,"image"); mysql_close(); $m = 0; $_SESSION['cart'][]= $title; $_SESSION['price'][]= $pricenon; if (empty($_POST['qty'])) { $_SESSION['qty'][]= '1'; } else { while (!empty ($_SESSION['cart'][$m])): //Trying to update quantity array here. I need to access the QTY box after clicking submit. Then I would like to search the $_SESSION['cart] array // and find the game I am looking for. Once I have found the game, I would like to set the corresponding QTY array equal to the updated value in the // text box. $m++; endwhile; } $totalprice = 0.00; } $i = 0; if (empty($_SESSION['cart'][$i])){ ?> <tr><td><?php echo "You have no items in your cart."; ?> </tr></td> </table> </div> <?php } else { ?> <form method="POST" action="cart.php"> <th>Quantity</th> <th>Game</th> <th>Price</th> <?php while (!empty ($_SESSION['cart'][$i])): ?> <tr><td><INPUT TYPE="text" NAME="qty?name=<?php echo $_SESSION['cart'][$i]; ?>" SIZE="1" value="<?php echo $_SESSION['qty'][$i]; ?>"></td> <td><a href="game.php?id=<?php echo $_SESSION['cart'][$i]; ?>"><?php echo $_SESSION['cart'][$i]; ?></a></td> <td><?php echo $_SESSION['price'][$i]; ?> </td></tr> <?php $totalprice+=$_SESSION['price'][$i] * $_SESSION['qty'][$i]; $i++; endwhile; ?> <tr><td><b><label>Price: </label></b></td> <td><label> </label></td> <td><?php echo $totalprice; ?> </td></tr> <tr><td><input type="SUBMIT" value="Update Cart" name="Submit"></td></tr> </table> </form> </div> <?php } require_once('footer.php'); ?>[/code]
  11. Took me a long time, but I finally found an answer: ini_set( "session.bug_compat_warn", "off" );
  12. Can anybody help me here? Warning: Unknown(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0 Also, I got this warning message and I'm not sure what it means. I can't turn register_globals on. Is there any way to fix this or an error in my code? Okay, I got rid of the message in the middle by separting the price out into a separate array such as: [code]$_SESSION['cart'][]= $title; $_SESSION['price'][]= $pricenon;[/code] However, I am still getting the error message above. I would assume I am getting this because I am using the $_SESSION variables. I can't turn globals on, so can somebody suggest an alternative? Thanks.
  13. I am doing something similar to this. I'm not sure if this will help, but I'll try to make a suggestion. I have a page that is being used as a template to output different games. What I am doing is putting the name of the game in the URL such as [code]www.mysite.com/page.php?id=name[/code] I'm sure you probably have a Session variable with the user name is it, so you could even use the session variable to define what the name is in the URL. Now on the template page, you can say: [code]$name =$_GET['id'];[/code] and then pull from your database where the name is equal to the user name assuming you are using the id as the username. Hope that helps.
  14. Try this: $query = "SELECT * FROM users WHERE `status` = '1'"; You only need to say WHERE once. So if you had more than one argument you would say 'status'='1' and name='Matt'
  15. $query = "SELECT * FROM users WHERE 1 AND WHERE `status` = '1'"; Do you mean to say this? $query = "SELECT * FROM users WHERE `status` = '1'";
×
×
  • 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.