...

View Full Version : Pending on submit



markman641
08-25-2011, 11:55 PM
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:


<?
$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..

mlseim
08-26-2011, 12:33 AM
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?


.

Mark91
08-26-2011, 01:31 AM
After you have created your button:

<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:

<?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.

markman641
08-26-2011, 01:54 AM
ok this is what I tried to do:


<?
$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

markman641
08-26-2011, 05:46 AM
anyone?

mlseim
08-26-2011, 02:20 PM
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.


.

markman641
08-27-2011, 01:53 AM
sorry i have no clue how to do it...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum