Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
im trying to make a forum site.
i make a page for contact us.
each comment sent ، come in the admin page.
admin dont know how many comment is in the page.
i put form for each comment with submit with for($i=1;$i<=$l;$i++);
i want to checked if(isset($_POST[''])){}
each one set
run for($i=1;$i<=$l;$i++){
if(isset($_POST['$i'])){
SQL
$del111=mysql_query("UPDATE contact SET state=1
WHERE id='{$i}'"
);
}
}
if the state be 1 means this comment readed and dont show this comment again
my problem is : if(isset($_POST['each one'])){
}
i want to check each one clicked do this query
Posted
Updated 10-Jun-14 0:25am
v2
Comments
Er. Tushar Srivastava 9-Jun-14 10:47am    
You might need to elaborate your question.... Use "Improve Question" to improve it. It is not clear what you are asking. Please improve the question or provide an example of what you want to accomplish.
Mohibur Rashid 9-Jun-14 18:40pm    
Try the code
$ispost=false;
foreach($_POST as $index =>$value)
{$ispost=true; break;}

Check out the following example, say you submit a form from registration.html page to acknowledge.php page
registration.html:
<form id="form1" action="acknowledge.php" method="post">
   <input type="text" name="fullname">
   <input type="submit" name="register" value="Sign up">
</form>

acknowledge.php:
<?php
    if (isset($_POST['register'])){ // the request is sent from registration.html
         echo $_POST['fullname'];  / output the value of fullname
    }
?>

Read more:
1. Beginner's Guide to HTML5 & CSS3 - Server Side Story[^]
2. php_forms[^]
 
Share this answer
 
v2
Not this way, of course.

The question is not clear, but most likely you come to this page either as a result of some post or not, and want to know if the post was actually done. This is really often needed, to know the difference and show different content in different cases. You can simply solve this problem by checking $_POST["???"] indexed by not an empty string, but some real name of a real control (the attribute value of the attribute name of some real control on your form). If you are using Ajax instead of the form (or in addition to the form posting), you can pass any key-value pair in the post data, so you can pass one just for the purpose of checking up if there is a post.

Another, really simple way of the check would be using a referrer. Suppose you can come to your page in two different ways: 1) from some page (usually the same one) which has the post data in HTTP request, 2) elsewhere, including direct typing of the URL in the browser's address line. In first case, you can expect post data, and not in other cases. You cal easily tell the first case from the second one by taking the referrer: $_SERVER['HTTP_REFERER']. The current page URI can be found as $_SERVER['REQUEST_URI'].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900