How to create a search URL for website using <select> - html

I am writing some code which will search a website and return the number of search results. A bit like this Number of Google Results from Excel but the site I am using is sciencedirect.com
Science direct is a bit odd in that the URL of the results page does not contain the search term, so finding the URL to send your search term is more complex. I have been reading the source code of the advanced search page and this is the relevant part of the code:
<form name="Form1" method="get" action="/science">
<input type="hidden" name="_ob" value="MiamiSearchURL">
<input type="hidden" name="_method" value="submitForm">
<input type="hidden" name="_acct" value="C000053194">
<input type="hidden" name="_temp" value="all_search.tmpl">
<input type="hidden" name="md5" value="9e299e9289462d7805ab0a5dcc9cff5c">
<input type="hidden" name="test_alid" value="">
<div class="contentMain" style="margin:1px 0 0 1px;"><div class="contentShadow"><div class="contentBorders">
<div class="searchFormBg">
<div style="text-align:right;">
Search tips
</div>
<div>
<a name="Skip Search"></a><label class="searchFormLabel" for="SearchText">Search </label>
<input type="text" class="inputBox" name="SearchText" id="SearchText" value="" size="60" maxlength="256"> in
<select name="keywordOpt" id="keywordOpt" size="1">
<option value="ALL" selected >All Fields</option>
<option value="TITLE-ABSTR-KEY" >Abstract, Title, Keywords</option>
<option value="AUTHORS" >Authors</option>
<option value="SPECIFIC-AUTHOR" >Specific Author</option>
<option value="SRCTITLEPLUS" >Source Title</option>
<option value="TITLE" >Title</option>
<option value="KEYWORDS" >Keywords</option>
<option value="ABSTRACT" >Abstract</option>
<option value="REFERENCES" >References</option>
<option value="ISSN" >ISSN</option>
<option value="ISBN" >ISBN</option>
<option value="AFFILIATION" >Affiliation</option>
<option value="FULL-TEXT" >Full Text</option>
</select>
</div>
<div class="searchFormField">
<select name="addTerm" id="addTerm" size="1">
<option value="0" selected > AND
<option value="1" > OR
<option value="2" > AND NOT
</select>
</div>
<div>
<input type="text" class="inputBox" name="addSearchText" id="addSearchText" value="" size="60" maxlength="256"> in
<select name="addkeywordOpt" id="addkeywordOpt" size="1">
<option value="ALL" selected >All Fields</option>
<option value="TITLE-ABSTR-KEY" >Abstract, Title, Keywords</option>
<option value="AUTHORS" >Authors</option>
<option value="SPECIFIC-AUTHOR" >Specific Author</option>
<option value="SRCTITLEPLUS" >Source Title</option>
<option value="TITLE" >Title</option>
<option value="KEYWORDS" >Keywords</option>
<option value="ABSTRACT" >Abstract</option>
<option value="REFERENCES" >References</option>
<option value="ISSN" >ISSN</option>
<option value="ISBN" >ISBN</option>
<option value="AFFILIATION" >Affiliation</option>
<option value="FULL-TEXT" >Full Text</option>
</select>
</div>
<div style="margin:5px 0;">
<label class="searchFormLabel" for="source">Include</label>
<div style="float:left;"><input style="cursor: pointer;" type="checkbox" id="journals" name="source" value="srcJrl" CHECKED></div><div style="float:left;padding-top:2px;margin-right:5px;" class="astPad"><label for="journals">Journals</label></div>
<div style="float:left;"><input style="cursor: pointer;" type="checkbox" id="books" name="source" value="srcBk" CHECKED></div><div style="float:left;padding-top:2px;margin-right:5px;" class="astPad"><label for="books">All Books</label></div>
</div>
<div style="clear:both;"></div>
<div>
<label class="searchFormLabel" for="Subscribed">Source</label>
<select name="Subscribed" id="Subscribed" size="1" onChange="checkFavoriteJournals(this, 'sources','Y', '');" style="width:200px;">
<option value="0" SELECTED>All sources</option>
<option value="1" >Subscribed sources</option>
<option value="2" >My Favorite sources</option>
</select>
</div>
<div style="clear:both;"></div>
<div>
<label class="searchFormLabel" for="Subject">Subject <span class="SDtxtNoteSmall">(select one or more)</span></label></div>
<div>
<div style="margin-right:10px;display:inline;float:left;"><SELECT Name="srcSel" Multiple Size = "4"><OPTION VALUE="1" SELECTED > - All Sciences -<OPTION VALUE="5"> Agricultural and Biological Sciences<OPTION VALUE="6"> Arts and Humanities<OPTION VALUE="18"> Biochemistry, Genetics and Molecular Biology<OPTION VALUE="7"> Business, Management and Accounting<OPTION VALUE="8"> Chemical Engineering<OPTION VALUE="9"> Chemistry<OPTION VALUE="11"> Computer Science<OPTION VALUE="12"> Decision Sciences<OPTION VALUE="13"> Earth and Planetary Sciences<OPTION VALUE="14"> Economics, Econometrics and Finance<OPTION VALUE="15"> Energy<OPTION VALUE="16"> Engineering<OPTION VALUE="17"> Environmental Science<OPTION VALUE="220"> Immunology and Microbiology<OPTION VALUE="19"> Materials Science<OPTION VALUE="20"> Mathematics<OPTION VALUE="21"> Medicine and Dentistry<OPTION VALUE="22"> Neuroscience<OPTION VALUE="466"> Nursing and Health Professions<OPTION VALUE="23"> Pharmacology, Toxicology and Pharmaceutical Science<OPTION VALUE="24"> Physics and Astronomy<OPTION VALUE="25"> Psychology<OPTION VALUE="26"> Social Sciences<OPTION VALUE="487"> Veterinary Science and Veterinary Medicine</SELECT></div>
<div class="txtSmall" style="display:inline;">Hold down the Ctrl key (or Apple Key) <br>to select multiple entries.</div>
</div>
<div style="clear:both;"></div>
From this I have constructed this URL
http://www.sciencedirect.com/science?_ob=MiamiSearchURL&_method=submitForm&_acct=C000053194&_temp=all_search.tmpl&md5=9e299e9289462d7805ab0a5dcc9cff5c&test_alid=&keywordOpt=TITLE-ABSTR-KEY&source=srcJrl=1&source=srcBk=1&Subscribed=0&onchange=Y&srcSel=1&DateOpt=2&SearchText=test
Which works on a &[inputname]=[value]& basis
Which should search for "Test" based on my criteria, unfortunately it returns an error "A source must be selected" the source is set with the Subscribed=0 part of the URL and seems to be working because changing the value changes the source.
The difference between the source and other fields is that source is that it uses not
so my question is how do I change the URL so that it returns results.

It looks like science direct uses a variable that has a unique value for each search (md5=9e299e9289462d7805ab0a5dcc9cff5c in your example). This value changes even if you do the same search.
I haven't done any detailed investigations, but if they do some checks on their side (such as checking cookies, ip address etc.) it can be difficult, if not impossible to do.

Related

perform action when button is clicked php

I'm trying to create a form using php in which the user will input some data, and I'll be able to store them in my database.
so far my code is this
<h1>Join Head Hunters <span class="colored-text">NOW</span>!</h1>
<form class="sform" method="get">
<input type="text" name="username" value="" placeholder="Username" method="get" maxlength="30">
<input type="password" name="password" value="" placeholder="Password" method="get" maxlength="30">
<input type="text" name="first_name" value="" placeholder="First name" method="get" maxlength="30">
<input type="text" name="last_name" value="" placeholder="Last name" method="get" maxlength="30">
<input type="text" name="address" value="" placeholder="Address" method="get" maxlength="80">
<input type="text" name="phone" value="" placeholder="Phone" method="get" maxlength="60">
<input type="text" name="mail" value="" placeholder="email" method="get" maxlength="40">
<input type="text" name="prof" value="" placeholder="Profession" method="get">
<input type="text" name="account" value="" placeholder="Bank Account" method="get">
<select multiple id="studies" class="specialColor" method="get">
<option value="highschool degree">Highschool Degree</option>
<option value="bachelors degree">Bachelors Degree</option>
<option value="MSc">MSc</option>
<option value="PhD">PhD</option>
<option value="MD">MD</option>
<option value="EdD">EdD</option>
<option value="JD">JD</option>
</select>
<select multiple="multiple" id="skillz" name="skillz[]" method="get">
<option value="administering programs">Administering Programs</option>
<option value="advising people">Advising people</option>
<option value="analyzing data">Analyzing data</option>
<option value="assembling apparatus">Assembling apparatus</option>
<option value="auditing financial reports">Auditing financial reports</option>
<option value="budgeting expenses">Budgeting expenses</option>
<option value="calculating numerical data">Calculating numerical data</option>
<option value="finding information">Finding information</option>
<option value="handling complaints">Handling complaints</option>
<option value="imagining new solutions">Imagining new solutions</option>
<option value="interpreting languages">Interpreting languages</option>
<option value="speaking to the public">Speaking to the public</option>
<option value="writing letters/papers/proposals">Writing letters/papers/proposals</option>
<option value="listening to others">Listening to others</option>
<option value="deciding uses of money">Deciding uses of money</option>
<option value="determining a problem">Determining a problem</option>
<option value="setting work/committee goals">Setting work/committee goals</option>
<option value="maintaining emotional control under stress">Maintaining emotional control under stress</option>
</select>
<select multiple="multiple" id="languages" name="languages[]" method="get">
<option value="english">English</option>
<option value="greek">Greek</option>
<option value="german">German</option>
<option value="japanese">Japanese</option>
<option value="spanish">Spanish</option>
<option value="italian">Italian</option>
<option value="french">French</option>
<option value="wookie">Wookie</option>
<option value="klingon">Klingon</option>
<option value="other">Other</option>
</select>
<input type="submit" class="button" name='create_account' value="Create Account"></input>
</form>
and the PHP for that:
<?php
$sservername = "localhost";
$susername = "root";
$spassword = "";
$sdbname = "projectDB";
mysql_connect($sservername, $susername, $spassword) or die("Cannot connect to server.");
mysql_select_db($sdbname) or die("Cannot select DataBase.");
if (isset($_POST["create_account"])) {
echo "<br><br><br><br><br>Button clicked";
//header("Location: signupsuccess.php");
$email_exp = '/^[A-Za-z0-9._%-]+#[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
//some error checking, now...
if (!preg_match($email_exp, $mail)) {
$error_message .= "<font color='red'>The Email address you entered does not appear to be valid.<br/></font>";
header("Refresh:0");
echo $error_message;
}
}
?>
Problem is that no matter how many times I try and press the button it never echos the "Button clicked" message and I can't figure out why!
Keep in mind, this is my first attempt on php and mysql. Any help? I've googled too much and I can't figure out my mistake.
<form class="sform" method="get">
if (isset($_POST["create_account"]))
A GET form will put the data in the query string, not the request body. $_POST won't be populated. Set the method to post.
Additionally, at present you are always going to output the Refresh 0 header, so it is quite likely that even if you did output the HTML then the page would refresh immediately and you wouldn't see it.

Chrome caches select menu

I have a select menu.
Example:
<select autocomplete="off"> <option value="" selected="selected">Select Quantity</option>
<option value="6" autocomplete="off">6</option>
<option value="12" autocomplete="off">12</option>
<option value="18" autocomplete="off">18</option>
<option value="24" autocomplete="off">24</option>
</select>
If the user selects a value and then navigates to a different page and back...the browser caches the selected value (even though I have switched off caching in the cache related headers).
How can I prevent Chrome from caching these select values?
Add autocomplete="off" to the form (not the select element):
<form autocomplete="off">
<select> <option value="" selected="selected">Select Quantity</option>
<option value="6" autocomplete="off">6</option>
<option value="12" autocomplete="off">12</option>
<option value="18" autocomplete="off">18</option>
<option value="24" autocomplete="off">24</option>
</select>
</form>

How can I put an <input type="text" in a multiple <select>?

I´m using the code below to get an input textfield next to each option in a multiple select, but what I get is a total mess. The first option is in the multiple select but the rest shows out of the select list.
Does somebody knows how can I make that? I´m sorry I can not post images.
I hope somebody can help.
Thanks.
<select name="cars" multiple>
<option value="audi">Audi</option>
<input type="text" name="Audi" value""/>
<option value="bmv">BMV</option>
<input type="text" name="BMV" value""/>
<option value="honda">Honda</option>
<input type="text" name="honda" value""/>
<option value="peugueot">Peugueot</option>
<input type="text" name="peugueot" value""/>
<option value="volkswagen">Volkswagen</option>
<input type="text" name="volkswagen" value""/>
<option value="opel">Opel</option>
<input type="text" name="opel" value""/>
</select>
Do your drop down list but put a generic textbox afterwards. On the submit action, get the value of the count and apply it to the selected value.
<select name="cars" multiple>
<option value="audi">Audi</option>
<option value="bmv">BMV</option>
<option value="honda">Honda</option>
<option value="peugueot">Peugueot</option>
<option value="volkswagen">Volkswagen</option>
<option value="opel">Opel</option>
</select>
<input type="text" name="Count" value""/>
That only allows 1 count per save. If you want to be able to submit counts for ALL models, use a label and an input for each kind: like so
<table>
<tr>
<td>
Audi
</td>
<td>
<input type="text" name="audi" value""/>
</td>
</tr>
<option value="bmv">BMV</option>
<tr>
<td>
BWV
</td>
<td>
<input type="text" name="bmw" value""/>
</td>
</tr>
</table>

iPad Chrome HTML click select option, but display another option

In PC Chrome & IE, it works. But in iPAD Chrome, when I select month or year, it display the option of day. And the code related as below.
<td class="label" nowrap="nowrap"><label for="InputLabel2">Fax Received Date To</label></td>
<td><label>
<INPUT TYPE="HIDDEN" NAME="InputLabel2" VALUE="D/2014/10/22:17:19:28">
<INPUT TYPE="HIDDEN" NAME="InputLabel2_dirtyFlag" VALUE="0">
<LABEL FOR="InputLabel2_day"></LABEL>
<SELECT ID="InputLabel2_day" TITLE="Day" NAME="InputLabel2_day" onChange="InputLabel2_update(this, this.form, null)">
<OPTION VALUE="-1" >
<OPTION VALUE="1" >1
<OPTION VALUE="22" SELECTED>22
<OPTION VALUE="31" >31
</SELECT>
---
<LABEL FOR="InputLabel2_month"></LABEL>
<SELECT ID="InputLabel2_month" TITLE="Month" NAME="InputLabel2_month" onChange="InputLabel2_update(this, this.form, null)">
<OPTION VALUE="-1" >
<OPTION VALUE="1" >January
<OPTION VALUE="10" SELECTED>October
<OPTION VALUE="12" >December
</SELECT>
---
<LABEL FOR="InputLabel2_year"></LABEL>
<SELECT ID="InputLabel2_year" TITLE="Year" NAME="InputLabel2_year" onChange="InputLabel2_update(this, this.form, null)">
<OPTION VALUE="-1" >
<OPTION VALUE="2013" >2013
<OPTION VALUE="2014" SELECTED>2014
<OPTION VALUE="2015" >2015
</SELECT>
find the issue, it is due to , it should not have the additional after , and once remove it, it works in iPad Chrome now. Thx all

Form not submitting files

For some reason the following form isn't submitting the file like it should and I'm unsure why, on the server side if I check $_FILES it is always empty however if I check say $_POST['article'] that submit just fine, so only the file isn't being received then does anyone see something wrong with this?
<form action="newindex.php?do=submit" enctype="multipart/form-data" method="post">
Subject:<br>
<input type="text" id="subject" name="subject"><br>
<textarea id="article" id="article" name="article"></textarea><br>
<div class="sliderimage"><h2 class="blockhead">Slider Image:</h2>
<table><tr><td><b>Image:</b><br>Dimensions should be 640x360.</td><td>
<input type="file" id="image" name="image"></td></tr>
<tr><td><b>Transition:</b></td><td>
<select id="transition" name="transition">
<option value="">Random</option>
<option value="sliceDown">slideDown</option>
<option value="sliceDownLeft">sliceDownLeft</option>
<option value="sliceUp">sliceUp</option>
<option value="sliceUpLeft">sliceUpLeft</option>
<option value="fold">fold</option>
<option value="fade">fade</option>
<option value="slideInRight">slideInRight</option>
<option value="slideInLeft">slideInLeft</option>
<option value="boxRandom">boxRandom</option>
<option value="boxRain">boxRain</option>
<option value="boxRainReverse">boxRainReverse</option>
<option value="boxRainGrow">boxRainGrow</option>
<option value="boxRainGrowReverse">boxRainGrowReverse</option>
</select></td></tr>
<tr><td><b>Caption:</b></td><td>
<input type="text" id="caption" name="caption"></table><br></div>
<input type="hidden" name="securitytoken" value="<?php echo $vbulletin->userinfo['securitytoken'] ?>" />
<div class="center"><input type="button" value="Preview" class="preview"><input type="submit" name="submit"></div>
</form>
You need to have an input specifying the max file size:
http://www.php.net/manual/en/features.file-upload.post-method.php
put the size attribute in the and this will work.
<input id="image" name="image" type="file" size = '50'"/>