i am trying to build a meta search engine.
I currently have the following code.
<form method="POST" action="google_basic.php">
<label for="service_op">Service Operation</label><br/>
<input name="service_op" type="radio" value="Web" CHECKED />
Web <input name="service_op" type="radio" value="Image" />
Image <br/> <label for="query">Query</label><br/>
<input name="query" type="text" size="60" maxlength="60"
value="" /><br /><br /> <input name="bt_search" type="submit"
value="Search" /> </form> <h2>Results</h1>
{RESULTS}
I need the form to have more than one action= ""(I realise a form can only have one action, i need the equivalent of 3 actions ="" ). The form needs to access 3 search engines and display the results. What is the best way to do this?? I know that javascript may an option but is not a solution for me as it may be switched off in the clients browser.
Any ideas on the best way to go about this??
TIA
You need to perform the 3 "actions" on the server (in or from the google_basic.php file). After POSTing to the server, you can perform an arbitrary number of "actions" from there.
See also: http://us2.php.net/manual/en/intro.curl.php
it only needs one action, then the action is what will display all 3 searches. so instead of having google_search.php, bing_search.php, and yahoo_search.php, combine them all into a generic search page that will display all 3
Related
I have a form which is super simple.
<input type="text" name="tel">
So basically user hits submit and save new record with only the Tel.
what i want is to allow the user to create many tel row in the database. I have found a few different way of doing this and would like to know which approach is the best.
1) is to duplicate my form and increment the number which means i would need to write a lot of code.
<input type="text" name="tel">
<input type="text" name="tel1">
<input type="text" name="tel2">
<input type="text" name="tel3">
submit would create 4 new rows but this method would create allot of coding for its intended purpose.
2) I found a few references to using a class but i haven't got the slightest idea where to start with classes.
is there a simpler way of achieving this or is option 1 my best bet?
Use it like this.
<input type="text" name="tel[]">
<input type="text" name="tel[]">
<input type="text" name="tel[]">
<input type="text" name="tel[]">
and on server side you can extract them as array.
foreach($_POST['tel'] as $tel=>$value)
{
echo $tel.' - '.$value;
}
I have a webpage with a form has 3 parameters, like
http://www.likeforex.com/currency-converter/fxconverter.php?f=euro-eur&t=usd-us-dollar&amt=1
I used .htaccess to rewrite the page to: f_t.htm/amt as:
http://www.likeforex.com/currency-converter/euro-eur_usd-us-dollar.htm/1
However, my question is when user change the value of amt(middle of the page), then the form is re-sumbited, and the re-sumbited page is still in parameter format. How to make the url in after rewrite format?
Anything wrong with the submit button, or anything else?
the form:
<form name="e" method="get" action="fxconverter.php">
the amt parameter:
<input type="text" id="amt" name="amt" size="16" maxlength="16" value="'.$amt.'" onclick="this.focus();this.select();" />'
the submit button:
<input type="submit" value="Convert" class="bt" />
the .htaccess line:
RewriteRule ^(.*)_([^_]+)\.htm/([^/]+)$ fxconverter.php?f=$1&t=$2&amt=$3 [NC]
Thank you very very much.
You cant use a form, regardless of POST/GET and expect the parameters to output like a url eg http://www.likeforex.com/currency-converter/euro-eur_usd-us-dollar.htm/1
What you need todo is change the form slightly and use javascript to build the url and then redirect.
<script>
function goForm(form){
f = form.elements["f"].value;
t = form.elements["t"].value;
amt = form.elements["amt"].value;
window.location.href = 'http://www.likeforex.com/currency-converter/'+f+'_'+t+'.htm/'+amt;
}
</script>
<form name="currencyForm" method="GET" action="">
<input id="f" name="f" value="euro-eur" type="hidden">
<input id="t" name="t" value="usd-us-dollar" type="hidden">
<input id="amt" name="amt" size="16" maxlength="16" value="1" onclick="this.focus();this.select();" type="text">
<input type="button" name="button" value="Click" onClick="goForm(this.form)">
</form>
Then you can take advantage of the mod_rewrite.
Tho personally I would scrap the GET(for the fancy url) and just use POST. search engines wont query your form so there is no advantage in using GET only that it may make it easier for someone thinking to scrape your content to digest its workings. Also remember anyone without javascript enabled wont be able to use the form with my solution.
I have a HTML form page with following code :
<form action="chainresult.php" method="post" enctype="multipart/form-data" />
<input type="hidden" name="MAX_FILE_SIZE" value="3145728"/>
<input type="file" name="userfile" id="userfile" size="30" />
<input type="submit" value="GET SEQUENCE" />
</form>
<form action="helix_info.php" method="post" enctype="multipart/form-data" />
<input type="hidden" name="MAX_FILE_SIZE" value="3145728"/>
<input type="file" name="userfile" id="userfile" size="30" />
<input type="submit" value="GET HELIX INFO" />
</form>
My page has two browse options and two submit options which takes the use to 2 php pages. I want to have only one browse option with two options that takes the user to 2 different php pages based on what the user clicks.
Any help is appreciated!
You will need to combine the two forms into one (you don't even necessarily need the form tags), use JavaScript or jQuery to capture the submit button click, evaluate the input value based on your validation rules that route the form submission, and then post the values to a form, likely through ajax.
You can submit multiple forms but you will have to use Javascript. It should be doable with jQuery without too much sweat and tears. Something like...
$("#my-submit-button").click(function(){
$("#first-form").submit();
$("#second-form").submit();
})
I am not sure I understand your question correctly, but if you want to be able to post data to two different URLs, with two different submit-buttons, having two different forms is the only way to do it with plain HTML.
However, it would be possible to use JavaScript. In that case you could mash both forms together, evaluate the input before sending any information, and the post the data to different URLs depending on the input, using AJAX.
It is worth noting that going down the JavaScript-road, you would make the form unusable for anyone who has disable JavaScript.
I would probably suggest that you make it a single form, point it to an URL that can handle either case. So you always post the data to the same URL, and the server-side code would have to evaluate the input and decide what to do with it. That case you don't eliminate users that doesn't have JavaScript activated.
Not sure if I understood the question properly, but you could use jQuery to change the action attribute of your form, depending on what the user chooses. Something among the lines of:
<form id="myform" action="dummy.php" method="post" enctype="multipart/form-data" />
<input type="hidden" name="MAX_FILE_SIZE" value="3145728"/>
<input type="file" name="userfile" id="userfile" size="30" />
<input type="radio" name="formtype" value="uploadscript1.php" /> Option 1<br>
<input type="radio" name="formtype" value="uploadscript2.php" /> Option 2<br>
<input type="submit" value="GET HELIX INFO" />
</form>
And in jQuery:
$('input[name="formtype"]').change(function(){
$('#myform').attr('action', $(this).attr('value'));
});
I am not sure about the jQuery part, but it should work ok. Try experimenting with that. :)
Using this approach you should be able to send the same data to two different forms.
I would like to make a button on my website that automatically logs me in on another website. I recon I can use either Javascript/jQuery or PHP/cURL to do this.
Which is the best way to go?
You may use either remote javascript or iFrame. Find more details here: http://kuza55.blogspot.com/2007/06/building-secure-single-sign-on-systems.html
Also checkout google's approach named SAML: http://code.google.com/googleapps/domain/sso/saml_reference_implementation.html
It depends what the website is. JavaScript and jQuery alone cannot be used due to the cross-domain policy. You could perhaps use a combination of cURL and AJAX to achieve something similar.
I think you might need to provide a little more information about the site, and exactly why you'd want to do this...
I'm not sure if this is exactly what you're looking for, but one thing I have done in the past is to mimic the login form on the site you want to log in to.
For example lets say you want to log in to 'example.com'. In the source code for the login page of 'example.com' you will find the html code for the login form.
Example
<form name="blabla" action="action.php" method="post">
<input type="text" name="username" />
<input type="password" name="password" />
<input type="sumbit" value="Login" />
</form>
Create a form on your site similar to the one you find in 'example.com'. If you want you can even hide the fields, include values to make it a one button login. The trick is making sure that the action has the actual url. For example if the form says 'action.php' for 'example.com' you would put 'http://example.com/action.php'
Example
<form name="blabla" action="http://example.com/action.php" method="post">
<input type="hidden" name="username" value="testuser" />
<input type="hidden" name="password" value="testpass" />
<input type="sumbit" value="Login" />
<form>
This will log you in to the site in most cases. If you don't want to leave your own site you can set a 'target' for the form to an iframe or something.
I have a form that generates new input fields via JavaScript on click.
the inputs are successfully added to the FORM with the desired naming convention.
<input type="text" name="util_name0" id="util_name0" value="" /><br/>
<input type="button" onClick="newUtil(this)" value="Add New" />
newUtil() adds:
<input type="text" name="util_name1" id="util_name1" value="" />
however after posting, print_r($_POST) only lists 'util_name0'.
Normally i'd paste some code, but that's all i really need to do at this point...
form is in an include called from parent.php.
Javascript is called in parent.php
JS:
function newUtil(el) {
var newval = util_count++;
$('#qty').attr('value', newval);
$(el).before('-------------<br />
<div class="newUtilField">
<label for="util_type'+newval+'">Type (i.e. gas, electric...) '+newval+'</label><br />
<input type="text" name="util_type'+newval+'" id="util_type'+newval+'" value="" /><br /><br />
<label for="util_name'+newval+'">Company Name</label><br />
<input type="text" name="util_name'+newval+'" id="util_name'+newval+'" value="" /><br /><br />
<label for="util_number'+newval+'">Company Number</label><br />
<input type="text" name="util_number'+newval+'" id="util_number'+newval+'" value="" />
</div><br /><br />');
}
After execute the js code that adding the new field, inspect the new element using Firebug (in Firefox) or Web Inspector (in safari and google chrome). If the new field is outside the form tag, then it will not be included to form submit.
If you can, please provide the structure of form and it's fields. Also, make sure that the page contain no other error, and the tag is well balanced, all open tag have been closed in the right place. Misplace closing tag might yield error and unexpected behaviour.
Is this behaving differently in IE than it is in Firefox? Run an HTTP sniffer (like Fiddler) on it check the HTTP post headers carefully.
Would recommend creating proper objects rather than creating the elements like that.
Create elements and inject them one by one.
EDIT : check link http://domscripting.com/blog/display/99