Reputation: 13
What is the best way to use a PHP table to hold comments from multiple different sections, and be able to distinguish between each different comments section? Is there some way to pass POST data without the need of a form?
Is there some way for me to distinguish between these two forms? Should I be using Javascript and distinguishing by the id of the forms, or is there a cleaner way?
<form action="SubmitComment.php" method="post" id="comments1">
<h3>Name:</h3><input type="text" name="name" cols="100">
<h3>Comment:</h3><input type="text" name="comment" cols="100">
<textarea rows=4 cols="100" placeholder="Enter text here!"></textarea>
<?php $_POST['section'] = 1; ?>
</form>
<!-- I want to be able to distinguish between these two forms. -->
<form action="SubmitComment.php" method="post" id="comments2">
<h3>Name:</h3><input type="text" name="name" cols="100">
<h3>Comment:</h3><input type="text" name="comment" cols="100">
<textarea rows=4 cols="100" placeholder="Enter text here!"></textarea>
<?php $_POST['section'] = 2; ?>
</form>
Upvotes: 0
Views: 472
Reputation: 972
There is a way to distinguish forms using
<input type="submit" name="form" value="form1">
to send data, in that way you can read $_POST['form']
value and check what form it is
If you want to send data without form you can use ajax with Javascript.
Upvotes: 2