Web Analytics Made Easy -
StatCounter Pending on submit - CodingForum

Announcement

Collapse
No announcement yet.

Pending on submit

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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..
    Ever want to see inside of a rave? Check out RedRoll and join our community of EDM lovers and rave fanatics.

  • #2
    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?


    .

    Comment


    • #3
      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.

      Comment


      • #4
        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; Aug 25, 2011, 09:11 PM.
        Ever want to see inside of a rave? Check out RedRoll and join our community of EDM lovers and rave fanatics.

        Comment


        • #5
          anyone?
          Ever want to see inside of a rave? Check out RedRoll and join our community of EDM lovers and rave fanatics.

          Comment


          • #6
            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.


            .

            Comment


            • #7
              sorry i have no clue how to do it...
              Ever want to see inside of a rave? Check out RedRoll and join our community of EDM lovers and rave fanatics.

              Comment

              Working...
              X
              😀
              🥰
              🤢
              😎
              😡
              👍
              👎