/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] How to affect only one form on a multi-forms page, upon $_POST[‘submit’]?

Hi,

I am trying to do a “Leave a feedback to the seller”, like on ebay.
It’s a page that displays all the items for which user has to leave a feedback.

And for each of those displayed items, there is a little Radio button (negative, neutral, positive) and a text input for comment.

The problem I’m having is that if ($_POST[‘submit’]) is SET, my “test string” is applied to all items that need to have a feedback. Obviously, I would like to display a message “You have successfully left a feedback” that will replace the radio buttons and text field for this SPECIFIC item.

I am showing you my code below.
Does anyone have a suggestion? Thanks a lot for your help

[code=php]
<?php
$query=mysql_query(“SELECT * FROM items WHERE buyer=’$username’ AND feedbackleft=’0′”);

echo “You have “.mysql_num_rows($query).” feedbacks to leave:<p>”;

while ($row=mysql_fetch_assoc($query))
{

if (isset($_POST[‘submit’]) && !empty($_POST[‘feedback’]) && !empty($_POST[‘comment’]))
{

echo ‘Test string’;

}

echo ‘<a href=”index.php?item=’.$row[‘item’].'”><b>’.$row[‘title’].'</b></a><br />’;
echo “Seller: “.$row[‘seller’].”<br />”;

?>

<form name=’feedbackform’ method=’POST’>
<input type=”radio” name=”feedback” value=”negative” /> Negative
<input type=”radio” name=”feedback” value=”neutral” /> Neutral
<input type=”radio” name=”feedback” value=”positive” /> Positive
<br />
Comment: <input type=’text’ name=’comment’>
<input type=’submit’ name=’submit’ value=’Submit feedback’>
</form><p>

<?php
}

?>
[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 03.2012 — First thought is to simply throw in a hidden input element with the user id of interest as its value.
Copy linkTweet thisAlerts:
@alex12345authorMar 03.2012 — Hi NogDog,

I worked it out thanks to your suggestion.

Thanks a lot!

Regards
×

Success!

Help @alex12345 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...