Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Jul 2011
    Posts
    272
    Thanks
    63
    Thanked 1 Time in 1 Post

    Pending on submit

    Hey, quick question, how would i use INSERT for a submit button? like on submit insert 'username', 'offername', 'date' VALUES '$usr', '$name', NOW()

    and then after that, i would like to so after its submit it wouldnt show up on their page anymore, this is the current code i have to show offers:

    Code:
             <? 
    				$get_name = mysql_query("SELECT `id`, `name`, `link`, `value`, `description` from `offers` WHERE `countries` like '%us%' ORDER BY id DESC LIMIT 0, 25");
     while($namerow = mysql_fetch_array($get_name)) {
      	$id = $namerow["id"];
    	$link = $namerow["link"];
    	$name = $namerow["name"];
    	$amount = $namerow["value"];
    	$desc = $namerow["description"];
    ?>
                 <center><b><a href="<?=$link?><?=$usr?>" target='_blank'><?=$name?></a></b> 
    <br><?=$desc?>
    <br><b><strong>Payout: <?=$amount?> Points</b></strong></center>
    <br><hr color="035096"><br>                            <? }?>
    something like where it checks the table pending for their username and if it is found it gets ID and removes the offer with that ID from their page?? sounds really confusing to me..

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,472
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    If the criteria is met (to not display it anymore), you have a couple choices.

    1) Have a column in your user table that you update with some kind of code.
    Each time you query that table, you can see if the user has been there or not.
    This method would be permanent, meaning if the user left and came back a day
    later, it would still not display it again. The only way to redisplay would be to update
    that column with a new code, or erase the code.

    2) You set a PHP SESSION variable that you can check each time you query. It would
    keep the display from showing. But, SESSION is only valid until the user closes their
    browser. If they came back the next day, they would once again see the form.

    So you have to think about how it is supposed to work, and whether or not you have
    several forms that need to be controlled? How permanent will the effect be?


    .

  • #3
    New Coder
    Join Date
    Sep 2010
    Posts
    35
    Thanks
    3
    Thanked 1 Time in 1 Post
    After you have created your button:
    Code:
    <input type="submit" name="submit" value="Submit" />
    You can use the following PHP code to execute whatever you want after the user has clicked the submit button:
    Code:
    <?php
    if(isset($_POST['submit'])){
    $user = $_POST['username'];
    $pass = $_POST['password'];
    mysql_query("INSERT INTO users (username, password)
    VALUES ('$user', '$pass')");
    }
    ?>
    That is very basic code but should point you in the right direction. You will need to filter user input and clean up the code.

  • #4
    Regular Coder
    Join Date
    Jul 2011
    Posts
    272
    Thanks
    63
    Thanked 1 Time in 1 Post
    ok this is what I tried to do:

    Code:
             <? 
    				$get_name = mysql_query("SELECT `id` from `members` WHERE `username`  = '$usr'");
     while($namerow = mysql_fetch_array($get_name)) {
      	$memberid = $namerow["id"];
    ?>
             <? 
    				$get_name = mysql_query("SELECT `id`, `name`, `link`, `value`, `description` from `offers` WHERE `countries` like '%us%' ORDER BY id DESC LIMIT 0, 25");
     while($namerow = mysql_fetch_array($get_name)) {
      	$id = $namerow["id"];
    	$link = $namerow["link"];
    	$name = $namerow["name"];
    	$amount = $namerow["value"];
    	$desc = $namerow["description"];
    ?>
                 <center><b><a href="<?=$link?><?=$usr?>" target='_blank'><?=$name?></a></b> 
    <br><?=$desc?>
    <br><b><strong>Payout: <?=$amount?> Points</b></strong></center>
    <br><br> <input type="submit" name="submit" value="Submit" /><?php
    if(isset($_POST['submit'])){
    $id = $_POST['id'];
    mysql_query("UPDATE offers SET users=<?=$memberid?>  WHERE `id` = <?=$id?>");
    }
    ?><hr color="035096">                           <? }?><? }?>
    whats wrong? when i click submit nothing happens
    Last edited by markman641; 08-26-2011 at 02:11 AM.

  • #5
    Regular Coder
    Join Date
    Jul 2011
    Posts
    272
    Thanks
    63
    Thanked 1 Time in 1 Post
    anyone?

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,472
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    I don't see a <form> tag ..
    Are you only showing us a small part of the script?

    You have to decide whether to use a submit button,
    within a <form> and using $_POST, or use a URL variable,
    within a link, and use $_GET.

    It looks like you're mixing things up.

    It might be easier to create a few separate scripts, where you
    first display the lists and options for the user, and then have
    a separate script for doing the updates.

    Seems like we're only seeing a few lines of code each time you post things here.


    .

  • #7
    Regular Coder
    Join Date
    Jul 2011
    Posts
    272
    Thanks
    63
    Thanked 1 Time in 1 Post
    sorry i have no clue how to do it...


  •  

    Posting Permissions

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