Reputation:
My URL contains parameters for database Query but when i submit my form on that same page these Parameters are gone .hence resulting in an error for database queries.
This is My URL
localhost/forum_original_code/article_details.php?article_id=3
This is the comment form i am trying to submit.
`<h4>Leave a Comment:</h4>
<form class="well form-horizontal" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post" id="contact_form">
<div class="form-group">
<textarea class="form-control" rows="3" name="comment"></textarea>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
`
But when i get the posted values the Parameters form URL are gone.
URL After form submission
http://localhost/forum_original_code/article_details.php
Again resulting in data base query error. Can somebody guide me how to approach this better. Thanks.
Upvotes: 0
Views: 39
Reputation: 158
Set action to
action="<?php echo htmlspecialchars($_SERVER["REQUEST_URI"]);?>"
It will return complete URL with query string.
$_SERVER["PHP_SELF"]
only gives you till localhost/forum_original_code/article_details.php
Upvotes: 0