how about when you down vote something you leave a comment on why you down voted so the poster has an idea how they can improve on the way they asked something
So I have an input field like so:
<form action="search.php?do=process" method="post">
<input type="hidden" name="do" value="process" />
<input type="hidden" name="quicksearch" value="1" />
<input type="hidden" name="childforums" value="1" />
<input type="hidden" name="exactname" value="1" />
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<input type="text" name="query" tabindex="1001" id="overlay-search" class="no-border overlay-search bg-transparent" placeholder="Search..." autocomplete="off" spellcheck="false" />
</form>
what I'm trying to accomplish is alternative buttons that will search the text in the input on say google.com but I have had no success in finding a solution to this =/
the way I'm trying to get it to work is like:
Not happy with your results? Try searching on google.
I have searched and searched and have found nothing related to this, although I doubt I'm searching the right thing. Any help in achieving this would be greatly appreciated =)
searches I'm considering on including:
Facebook
Google
Bing
Yahoo
and more
A simple solution will be getting the value of the posted input field and just echoing out .Before that you must add a submit button at the end of your form.
<input type="submit" name="submit" value="Search"/>
And then do something like below in your search.php file.
<?php
// Check if the submit button is clicked
if(isset($_POST['submit'])) {
// And then do something
echo 'Not happy with your results?Try searching on google.";
}
?>
Related
We have a large search box on our homepage that just stopped working after a recent update from our vendor. I'm trying to debug the issue but I could really use an extra set of eyes. Instead of returning a list of courses it's returning "?query" to the current page URL. Any help would be greatly appreciated.
Affected Page: https://ce.harpercollege.edu/
Code:
<form action="https://ce.harpercollege.edu//search/publicCourseAdvancedSearch.do" class="search-form" id="search-form" method="GET" role="form" target="_blank">
<label for="quick-search">BECOME MORE</label>
<span class="search-btn-span" id="search-btn-span">
<input name="method" type="hidden" value="doPaginatedSearch" />
<input name="showInternal" type="hidden" value="false" />
<input name="cspIndex" type="hidden" value="true" />
<input name="isPageDisplayed" type="hidden" value="true" />
<input class="form-control" name="courseSearch.courseDescriptionKeyword" placeholder="Search Course Number, Title, or Keyword..." type="text" />
<button type="submit"></button>
</span>
</form>
Working Search URL:
https://ce.harpercollege.edu/search/publicCourseAdvancedSearch.do?method=doPaginatedSearch&showInternal=false&cspIndex=true&isPageDisplayed=true&courseSearch.courseDescriptionKeyword=garden&courseSearch.disciplineCode=&courseSearch.partialCourseNumber=&courseSearch.courseCategoryStringArray=0&courseSearch.sectionSemesterIdString=&courseSearch.sectionInstructorName=&courseSearch.sectionAccreditingAssociationStringArray=0&courseSearch.sectionDayOfWeekStringArray=0&courseSearch.sectionStartTimeStringArray=0&courseSearch.sectionStartMonthStringArray=0&courseSearch.filterString=availforreg
I managed to fix the issue. An old script was hiding in JS and was breaking the form. Sorry for being a bother.
Using <form method="get"> element including <input type="submit"> element, we can have a way to GET a web page with some fields specified by the <input type="text" name="studentId"> elements, but can I customize those fields?
For example: I always want to add a action=true to the GET url to let the URL be something like this: http://example.com/?studentId=123&action=true?
Use <input type="hidden" name="action" value="true" />
inside your form.
You can add a hidden form field, though the name action is not a good one, as form has an action attribute and this name can conflict when scripting the form:
<input type="hidden" id="something" name="something" value="somthingelse" />
<div id="gbqffd">
<input type="hidden" value="en" name="h1">
<input type="hidden" value="d" name="tbo">
<input type="hidden" value="search" name="output">
<input type="hidden" value="psy-ab" name="sclient">
</div>
Google always has the answer; in this case I never had to do a search just look at the source :)
I'd like to add search to a static site. The simplest way is to simply query Google by appending "site:www.acme.com" to the actual query so that Google will limit search to that site.
Ideally, I'd like to do this in the browser, to avoid having to install PHP on the server. Using a form, I don't know how to append the search items:
<form action=http://www.google.com?q="site:www.acme.com+...">
<input type=text id=search_item>
</form>
Does someone know of a client-side solution? Should I use some JavaScript for this?
Thank you.
Edit: When using "method=get" and "input name=q value="site:www.acme.com "", the browser will indeed call Google with "www.google.com?q="site:www.acme.com some item", but I'd rather avoid presetting the input box with "site:www.acme.com" because users will find this odd and might remove it.
You just need to set the form method to "get", add one extra hidden element with the site you want to search and it will automatically paste it behind the URL as such:
<form action="https://google.com/search" method="get">
<input type="hidden" name="sitesearch" value="http://acme.com" />
<input type="text" name="q" />
</form>
Because that is how HTML forms work by default.
u can do something like this:
<script type="text/javascript">
function google_search()
{
window.location = "http://www.google.com/search?q=site:www.acme.com+" + encodeURIComponent(document.getElementById("q").value);
}
</script>
<form onSubmit="google_search()">
<input type="text" name="q" id="q" value="" />
<input type="submit" value="search" onClick="return google_search()" />
</form>
<form method="get" action="http://google.com/search">
<input type="text" name="q" required autofocus>
<input type="submit" value="Google search">
</form>
If you want to use Bing Search engine then replace 'google' with 'bing'.
I have done this a lot of times but I have a problem, I'm trying to do it with the google form, the google name have slashes so is not working on all browsers, is there a different way to do this?
Any clue is good :D
code:
<form action="http://www.webpage.com/search.php" id="cse-search-box" name="cse-search-box">
<div>
<input type="hidden" name="cx" value="partner-pub-number" />
<input type="hidden" name="cof" value="FORID:number" />
<input type="hidden" name="ie" value="ISO-8859-1" />
<input type="text" name="q" size="31" class="form-search" />
<a name="sa" id="sa" href="javascript:document.cse-search-box.submit();"><img src="images/arrow.jpg" class="img-search"/></a>
</div>
</form>
<input type="image" src="path/image.png" />
<input type="image" ...> is what is used for images acting as submit buttons.
- is the minus operator, so document.cse-search-box doesn't mean what you think it does -- further, this way of accessing elements is obsolete. Use getElementById instead:
document.getElementById('cse-search-box').submit();
Actually, you don't even need JavaScript to do this. There are at least 2 ways to do it using HTML alone:
<input type="image" src="images/arrow.jpg" />
or:
<button type="submit"><img src="images/arrow.jpg" /></button>
I have a simple form which passes the value of an <input /> element:
<form action="updaterow.php" method="POST">
<input type="text" name="price" />
</form>
How can I post extra values along with the <input /> value? For example, an arbitrary string, or a variable inside the current PHP script.
I know this is possible with GET:
<form action="updaterow.php?foo=bar" method="GET">
<input type="text" name="price" />
</form>
or:
<form action="updaterow.php?foo=<?=htmlspecialchars($bar)?>" method="GET">
<input type="text" name="price" />
</form>
but I need POST.
You can include a hidden form element.
<input type="hidden" name="foo" value="bar" />
You can simply use a hidden field. Like so:
<input type="hidden" name="your-field-name" value="your-field-value" />
This field will then be available in your PHP script as $_POST['your-field-name']
As mentioned already, using hidden input fields is an option, but you can also use a session. That way you donĀ“t have to post anything, the variables remain on the server and are not exposed in the html.