Jump to content

Amster

New Members
  • Posts

    8
  • Joined

  • Last visited

Amster's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok thank you but how would I go about displaying the quantity I have of each item on my site?
  2. I've only made `item1`, `item2` in the database so far but I intend on making the rest. Shouldn't it still be outputting the values of `item1`, `item2` or does it requires me to put every field first in the database? Edit: I tried changing it from <100 to <2 and it still echoes nothing.
  3. Hello, I want to use a loop to assign a new variable to a different value from my database. So for example, $item[1] = 'item1' from my database, $item[2] = 'item2' from my database and so forth until 'item100'. I have tried using the following code: $rs_settings = mysql_query("select * from users where id='$_SESSION[user_id]'"); while ($row_settings = mysql_fetch_array($rs_settings)) { for( $i = 1; $i < 100; $i++ ) { $item[$i] = $row_settings['item . $i']; } } And the following code for output: for( $i = 1; $i < 100; $i++ ){ echo $item[$i]; } ?> But it just echoes nothing. Could someone help me with my code so I can get this working? Thanks!
  4. My server collects error logs I think. I decided to scrap the confirm part anyhow, I just want the points to subtract properly. I tried doing this, which sort of works, it actually removes 400 points but delete the submit button for unknown reasons in the process. Then when I refresh again, everything seems fine. I don't know why the submit button disappears though. if($_POST['Purchase1'] == 'Purchase Item'){ if ($points > 400){ mysql_query("update users set points = points - 400 WHERE id='$_SESSION[user_id]' ") or die(mysql_error()); $_POST['Purchase1'] = ' '; header("Location: admin.php"); exit(); } } ?>
  5. But why would it reload when I reload the form? If I didn't click the button again when I reload the site, why should it? Also I have feeling the confirmation button isn't work as it's reading the php first and set $checker=1 before it reads the javascript but I'm not sure how to correctly fix this. Thanks for your help anyway though
  6. I'm not exactly sure if it's the submit button at fault. The thing is I go to the page initially and reload, no points are removed. It's only after I click the submit button once, it removes 400 points but then after that if I keep refreshing the page without clicking the button, it continues to keep removing 400 points on each refresh. Its like once I press the "submit" button once, it does it automatically on each refresh.
  7. Hello, I've created a script that should remove 400 points when I click a button "Buy Item". The problem is that when I run this script, it removes the 400 points, but continues to do so every time I load the page whether or not I click the "Buy Item" button. Also, it shows my warning asking if I want to buy an item but seems to disregard my choice and purchase the item either way. How can I fix this? I simply want a script that when I click the button, it removes 400 points, reloads the page displaying the new amount of points I have, and works properly! Thanks! EDIT: I should note that when I have under 400 points, it does not subtract anymore. This part actually works properly. Here's the code: <h5 class="titlehdr">Store<br></h5> <?php $rs_settings = mysql_query("select * from users where id='$_SESSION[user_id]'"); ?> <?php while ($row_settings = mysql_fetch_array($rs_settings)) { ?> <font size="2"> Points: <b> <?php $points= $row_settings['points']; echo $points; $checker = 0; } ?></b></p> <?php if($_POST['Purchase1'] == 'Purchase Item'){ if ($points > 400){ ?> <script> var r=confirm("Are you sure you want to buy this?"); if (r){ <?php $checker = 1; ?> } </script> <?php if ($checker == 1){ mysql_query("update users set points = points - 400 WHERE id='$_SESSION[user_id]' ") or die(mysql_error()); $_POST['Purchase1'] = ''; $checker=0; header("Location: /store.php"); } } } ?> <td width="196" valign="top"> </td> <tr> <form name="store" method="post" id="store"> <table width="80%" border="0" align="center" cellpadding="3" cellspacing="3" class="forms"> <p align="center"> Item 1<br> 400 points<br><br> <input name="Purchase1" type="submit" id="Purchase1" value="Purchase Item"> </p> <p> </p> </form> <td colspan="3"> </td> </tr> </table> </body> </html>
  8. I am using the php-login script. Everything has been working fine but suddenly now when I try logging in with an account (called user1) that has always worked previously, it simply redirects me to the login page. It does not error, it just redirects. Although if I try another account (user 2), I login normally but this one account (user 1) just does not seem to not want to login and just keeps redirecting me back when I try logging in. Also, the script only works if I have the "Remember Me" box checked. I have a feeling that it is an issue with cookies, I have taken a code snippet here: session_start(); session_regenerate_id (true); //prevent against session fixation attacks. // this sets variables in the session $_SESSION['user_id']= $id; $_SESSION['user_name'] = $full_name; $_SESSION['user_level'] = $user_level; $_SESSION['HTTP_USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']); //update the timestamp and key for cookie $stamp = time(); $ckey = GenKey(); mysql_query("update users set `ctime`='$stamp', `ckey` = '$ckey' where id='$id'") or die(mysql_error()); //set a cookie if(isset($_POST['remember'])){ setcookie("user_id", $_SESSION['user_id'], time()+60*60*24*365, "/"); setcookie("user_key", sha1($ckey), time()+60*60*24*365, "/"); setcookie("user_name",$_SESSION['user_name'], time()+60*60*24*365, "/"); } header("Location: myaccount.php"); Although, it may be other things. For further reference, the script I am using is from here: http://php-login-script.com Thanks!
×
×
  • 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.