www.webdeveloper.com
Results 1 to 2 of 2

Thread: Submit Button to Deduct Credits When Logged In

  1. #1
    Join Date
    Jun 2011
    Posts
    12

    Submit Button to Deduct Credits When Logged In

    My goal is to have info from a database echoed out and then available to be purchased by pressing a button. The info is being echoed properly but when the button is pressed it adds the $cost variable up for all of the qualifying variable vs the single one that it should be attached to... hopefully that makes sense.

    Also, when I refresh the page the "credits" are deducted from the users account, I was under the impression that a button would stop this from happening...

    PHP Code:

    $get 
    mysql_query("SELECT * FROM ac WHERE state='Alabama' ORDER BY datetime DESC LIMIT $start$per_page");

    while (
    $row mysql_fetch_assoc($get))
    {

    $cost $row['cost'];

    $submit $_POST['submit'];

    if (
    $submit)
    {
    if(
    loggedin())

    if (
    $credits<$cost)
        {
        
    $option2 "../../buycredits.php";
        }
        else
        {
        
    $option2 "ac_alabama.php";                
        
    $get;
        
    $deduct mysql_query("UPDATE users SET credits=credits-$cost WHERE username='$username'");
        }
    }
    else 
    $option2 "home.html";
    }    
                
    echo
    "
    <form action='
    $option2' method='POST'>
    <input type='submit' name='submit' value='Purchase'>
    </form>
    "
    ;

    Any and all help is greatly appreciated!

    Thanks in advance.

  2. #2
    Join Date
    Jun 2011
    Posts
    12
    Nevermind! I figured out what the issue was. Thanks anyways.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles