i used a form to POST the parameters to categories.php
<form action="categories.php" method="POST">
<fieldset>
<legend>Filter Categories</legend>
<p>
<label><input type="checkbox" name="categories[]" value="music"/> Music</label>
<label><input type="checkbox" name="categories[]" value="technology"/> Technology</label>
<label><input type="checkbox" name="categories[]" value="film"/> Film</label>
</p>
</fieldset>
<button type="submit">Filter</button>
<button type="reset">Reset</button>
</form>
So if I would to filter Music and Film the URL would look like:
http://domain.com/categories.php?categories[]=music&categories[]=film
the parameters will be hidden since i used POST and thats how i want it i don't want to see the parameters BUT....i have some links in my site that link to single categories i.e.
Categories:
Music (links to http://domain.com/categories.php?categories[]=music)
Film (links to http://domain.com/categories.php?categories[]=film)
now when someone visits the categories.php page trough an URL like that it will give me errors because i USED POST and not GET now how will i be able to GET those parameters still?
Thanks
That is the problem when using POST to show the user some content.
It is impossible to bookmark or create a link so they can see it again without posting the same POST data every time.
Why is it that you don't want your users to be able to see the search terms on their address bar?
Since it's not a security problem I'm assuming it's because those links don't look good, in which case I'd point you to start using clean urls.
Related
I have a WordPress site at www.itzfizz.com and have this custom SEO tool on this page https://itzfizz.com/seo-analyzer/ which basically tells the user the different ways to improve the content of a page/blog
I am trying to create a sidebar widget on my blog posts, where if a user types in their site, the query transfers from the search on the blog sidebar onto the SEO analyzer search bar.
I've used
<form method="get" action="https://itzfizz.com/seo-analyzer/?p=text">
<input type="text" name="keyword" />
</form>
<button type="submit">Analyze Website</button>
but the query isn't transferred to the SEO analyzer page (Search Box) as the URL is static, can someone recommend options I can follow.
Thanks a ton
Several things to fix:
The p parameter should be removed.
The url parameter which is the URL of the website to be analysed is missing in your form.
The submit button is outside the form, so it doesn't do anything
The output and ref parameters are missing. Since they are fixed they can just be hardcoded as hidden.
Here's the complete code for the form.
<form method="get" action="https://itzfizz.com/seo-analyzer/">
<input type="hidden" name="output" value="html"/>
<input type="hidden" name="ref" value="https://itzfizz.com/seo-analyzer/"/>
<input type="url" name="url" placeholder="https://www.yoursite.com" />
<button type="submit">Analyze Website</button>
</form>
I have a simple form with two slider and two buttons created using links, because truthfully those links are images created with css.
So, I want to be able to send all slider values when you click the button and then retrieve those values in the second div to show it.
I want to do it using PHP, so I think the best way is to send over POST and then retrieve it using the same way.
</br></br></br>
<div class="main">
<form method="post" action="">
<input type="range" name="val1" id="val1" value="5" min="0" max="10" data-show-value="true"></br>
<input type="range" name="val2" id="val2" value="5" min="0" max="10" data-show-value="true">
</br>
</form>
</div>
<a class="btn1" href="#">Button 1 - View 1 (Sliders)</a></br>
<a class="btn2" href="#">Button 2 - View 2 (Results)</a>
<div class="second">
<p>--Second div---</p>
<p>--Value 1---</p>
<?php $_POST['val1'] ?>
<p>--Value 2---</p>
<?php $_POST['val2'] ?>
</div>
At first I want to know how to pass values between pages and then when you come back to the main view put the value selected before. I think this can be done using $_SESSION.
So, what do you suggest to get the values from the each slider and put it in the second div using PHP?
I want to develop a dynamic site when depends on the button that you click go to one page or another. I have nearly 20 possibilities depends on the button clicked, so I think that the best way is using divs and putting all the PHP and HTML code in a file and show or hide depends on the button that you click.
And I using bootstrap-slider library, but to do the example I used the jquery slider.
I've done a fiddle to see if someone is able to do it.
https://jsfiddle.net/dperezq/ph7mfu0v/
Imagine taking a quiz at mysite/test/universe (URL = 'universe') or mysite/test/earth (URL = 'earth'). After you select the answers and click the Submit button, you're forwarded to a static page at mysite/test/results.php. The form automatically forwards some test data (e.g. $answer1 = $_POST['q1']).
Is there a way to modify the script so that, when someone clicks the Submit button, the page's URL is also captured and forwarded to the results page?
I don't want the URL itself to change. For example, if people are forwarded to mysite/test/results%universe, or something like that, then they could just visit that URL to see all the answers.
So I just want to forward the value of the URL, which I can then use to display and style correct and incorrect answers, along with feedback.
I should also explain that I'm working with PHP, jQuery and perhaps AJAX, and my ultimate goal is to modify my tests so that users can log in, and the test results will be published to a database. With that in mind, what's the best way to modify the HTML below so that the page URL is captured and forwarded to the results page?
<div id="quiz" rel="key" style="width: 500px; margin: 10px auto;">
<form action="grade.php" method="post" id="quiz">
<ol>
<li id="q1">
<div class="Question">No one knows if there’s just one universe or a series of universes, sometimes referred to as a:</div>
<div class="Answer">
<label for="q1-A"><div class="Radio"><input type="radio" name="q1" id="q1-A" value="A" style="display: none;"> A. multiverse</div></label></div>
<div class="Answer">
<label for="q1-B"><div class="Radio"><input type="radio" name="q1" id="q1-B" value="B" style="display: none;"> B. parallel universe</div></label></div>
</li>
</ol>
<input type="submit" value="Submit Quiz" />
</form>
</div>
Have a hidden field in your form
<input type="hidden" id="url" />
and set its value with this javascript
document.getElementById("url").value = document.URL;
or this jQuery
$(document).ready(function(){
$("input#url").attr("value", $(location).attr('href'));
});
then it will be submitted with the form.
you can use query string. if your first page url in http://something.html and second page url after form submit is another.html then
<form action="another.html?previous=<?php echo $_SERVER['REQUEST_URI']; ?>">
</form>
In another.html, you can get previous page url before submitting form by using GET
$_GET["previous"]
I have a problem in my php form :
isbn number is a GET variable .
Thus view.php opens in a URL like : localhost/../view.php?isbn=0810982463. Whereas I want the url structure to be like localhost/..../0810982463. I know it can be done by using the Post method, Can it be done using the GET method ?
<form action="view.php" method="get">
<p class="name">
<label for="isbn">ISBN No. </label>
<input type="text" name="isbn" id="isbn" value="0199555311">
</p>
<p class="submit">
<input type="submit" value="Search Book" />
</p>
</form>
No matter what, the GET form submission will be in a query string format, just look at Google's form submission, or even Stack Overflow's own searching. This is the way things have been standardized across browsers.
If you want it to look pretty, after the submission, you'll need to redirect the user to a pretty URL.
We have a searchbox shown below where users can enter a value, say 1234 ABC street, click Search and the results get displayed.
<!--form1 -->
<div id="inputBG">
<form id="searchForm" class="search_field" method="get" action="">
<input name="searchBox" id="searchBox" value="3440 Mark Drive" />
<button type="button" onclick="searchMap()"><img src="Viewer/images/search.png" alt="Search" /></button>
</form>
</div>
This works great.
If, however, users wish to display more than one type of results, the user clicks on an icon called Advanced Search. When this happens, a form with only checkbox shown below opens up in a new window.
<!--Form2 --->
<div id="featuresDiv">
<form id="featuresForm">
<br/>
<input type="checkbox" name="srcoptions" onClick="checkAll(this.form,this)" checked>Check/Uncheck All<br>
<label><input type="checkbox" name="featType" checked value="Addresses">Addresses</label><br/>
<label><input type="checkbox" name="featType" checked value="Voter Precincts">Voter Precincts</label><br/>
<label><input type="checkbox" name="featType" checked value="Voter Precincts (Pending)">Voter Precincts (Pending)</label><br/>
<label><input type="checkbox" name="featType" checked value="Voting Polls">Voting Polls</label><br/>
<label><input type="checkbox" name="featType" checked value="Voting Polls (Pending)">Voting Polls (Pending)</label><br/>
<label><input type="checkbox" name="featType" checked value="Zip Codes">Zip Codes</label><br/>
<label><input type="checkbox" name="featType" checked value="Zoning Petitions">Zoning Petitions</label><br/>
<button type="button" onclick="searchMap()"><img src="MapViewer/images/magnifying_glass.png" alt="Search" /></button>
</form>
</div>
Users have the option of checking all boxes or just a couple of boxes.
When the user clicks on Search, the results of those checked boxes are supposed to be displayed.
In situations where checkbox option is used, and more than one boxes are checked, the searchbox becomes irrelevant in the search.
I have tried several things and nothing seems to work so far.
When I use the checkboxes option and check more than one options, I get custom message that "Your search returned no results"
Here is the Javascript we have attempted which is supposed to show when the search is from searchbox (form1) or checkbox (form2).
Then we have php that is supposed to grab all search values (searchbox or checkbox) in to comma-separated values.
This has been driving us nuts for over 3 days now.
It is noteworthy to point out that the searchbox has a default value of 3440 Mark Street.
I am really stumped.
Any help is greatly appreciated.
// Construct query
**$features = $_GET["featType"];**
$tsql = "SELECT * FROM globes AS TBL
WHERE KEY_TBL.RANK > 0
ORDER BY ListOrder, Name, TBL.RANK DESC";
Some more information about what happens in doGlobalSearch and how the data is processed in PHP would be helpful. Offhand I'd guess there's some discrepancy in how the data sent to PHP is formatted and how it is expected to be formatted. Taking a total stab in the dark, have you tried just doing featureList = features.join()? Are you sure the individual values need to be quoted?
Just a suggestion, but here's how I would do it:
Combine the two forms into one.
Default all checkboxes to unchecked (or disable them) while the advanced search div is hidden.
Check (or enable) them when the advanced search div is shown.
Add [] to the end of each checkbox name so that the (checked) values are passed to PHP as an array when the form is submitted.
This way PHP would directly receive the searchData and featTypes (if any) together and you wouldn't have to parse the featTypes back out from a string in PHP. Then all you would need to do with javascript is submit the form and process the response. Again, this is without knowing what's going on in the backend or what control you have over it.