how to get in url with value.html - php

This form submits url like that
http://www.website.com/page/search.php?search=demo&submit=Search
<form action="search.php?search=" method="GET" id="search-form">
<input id="search-text" name="search" type="text" maxlength="30" placeholder="type keyword"/>
<button type="submit" name="submit" value="Search" id="search-button">Search</button>
</form>
Where I want to post the form like that:
http://www.website.com/page/search/demo.html
How can I do this?
I know it is a small thing but help me..
Thanks

I am unclear what your question is.
If you mean that you want to be able to process the input client-side, that is not possible unless you override the behavior with javascript. For example with jQuery
$( "search-form" ).on( "submit", function( event ) {
// Do stuff here with the form data
event.preventDefault();
});
If you mean that you don't want .php to show up and want to hide the underlying server technology, then you can use something like Apache's mod_rewrite. But you probably don't want that in this case because .html implies that it's a page you visit (GET, not POST) rather than a script you submit variables to.

Save this code as form.html on your desktop then open it with your browser then add some values and click the button. Look at the url afterwards
<form method="get" action="#">
<input type="text" name="input1">
<input type="text" name="input2">
<input type="text" name="input3">
<input type="text" name="input4">
<button type="submit">Click me and look at the url</button>
</form>

After seeing your edited question, try this with the above steps( save on the desktop etc.etc)
<form method="post" onsubmit="this.action=window.location.href.replace('.html',inputurl )">
<input type="text" name="input1" onblur="inputurl='/'+this.value+'.html'">
<button type="submit">Click me and look at the url</button>
</form>

Related

achieve send file in php chat like facebook chat

I have a chat and i would want to send files also during chat. I would want the same approach like facebook has: when you put the file it should not put into the specific textbox that comes with input=file and to not have the browse button? is this doable?
<form method="POST" name="form1" action="" id="myForm" enctype="multipart/form-data">
<input name="message" type="text" id="textb" value="" />
<input name="submit" type="submit" value="Chat" id="post_button"/>
<input type="file" name="fisier">
</form>
That's done with a combination of CSS and javascript.
Take a look at: http://www.dropzonejs.com/

Facebook iframe - how to send form (POST method)?

I have very simple form (the file is called message.php):
<?php
print_r($_POST);
?>
<form method="post" target="_top" action="<?php echo CANVAS_URL;?>message.php">
<input type="text" name="your_name" />
<input type="hidden" name="signed_request" value="<?php echo $_REQUEST['signed_request'];?>" />
<input type="submit" name="send" />
</form>
I found one solution of this issue - put into the form hidden input with the signed_request - I did it but unfortunately I am still facing with this problem -- I cannot retrieve sent POST data.
If I change the method to method="get", everything is working well, but I would need to data from POST.
Could anyone help me, how to solve this problem? Thanks!
Try this. I don't believe you need to use target in FB canvas aps anymore. Also a form ID would be good.
<form method="POST" id="my_form" action="message.php">
<input type="text" name="your_name" />
<input type="hidden" value="<?php print $_POST["signed_request"] ?>" name="signed_request" />
<input type="submit" name="submit" />
</form>
POSTing to Canvas URLs (as in http://apps.facebook.com/namespace) is simply not supported.
But why post to the top window instead of simply staying within the iframe? It's way better as it doesn't require the entire page to be reloaded, only the iframe.

add query on href using input

I have an
<input type=text name=search />
and I wanted to add the value of input to my href
<a href='index.php?search=$search>submit</a>
But I think that won't work on php alone right?
How can I add the value of my input to my href as it clicks?
NOTE: need to appear in the browser url menu this way
index.php?search=anyvalue
as soon as they click it. because I'm using pagination
Straight HTML - no PHP or JavaScript Needed
<form action="index.php" method="get">
<input type="text" name="search" />
<button type="submit">Submit</button>
</form>
Once clicked it will take the user to: index.php?search={value of input}
For pagination to work it would be:
Page 2
Page 3
try this:
<form method="get" action="index.php">
<input name="search" type="text" />
<input type="submit" />
</form>
If that's not what your looking for just elaborate a bit on what you are trying to achieve.
you must open a php tag like this:
<a href='index.php?search=<?php echo $search;?>' >submit</a>
but it work after submitting the form.
use javascript

URL rewrite with form and 3 parameters

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.

Zend_Form not submitting

I built a custom Zend_Form "myForm" and I passed it to my view with:
$this->view->form=new myForm();
Problem: form is not submitting (page doesn't reload/refresh).I thought something was wrong with the "form" tags,but I copyied the bottom code in another page (that is not a Zend environment) and is working.This is the source code:
<form enctype="multipart/form-data" method="post" action="">
<input type="text" name="title" id="title" value="" class="">
<textarea name="text" id="text" class=""></textarea>
<input type="text" name="allegati" id="allegati" value="" class="">
<input type="hidden" name="MAX_FILE_SIZE" value="2097152" id="MAX_FILE_SIZE">
<input type="file" name="file" id="file" class="media[]"></span>
<input type="submit" name="submit" id="submit" value="submit" class="">
</form>
SOLVED: As some of you guys suggested javascript is giving problems:
I had a js script overriding with:
$('form').submit();
Thanks
Luca
Form submitting issues are 99% related to javascript conflicts with the 'form' element or with a wrong defined 'form' tag.
Always check those above when encountering problems.
P.s. for the remaining 1% feel free to ask at Stack!
Best regards
Just a suggestion - try to rename your submit button to something but not "submit" (i.e name="mysubmitbutton").
I think the problem could be with expandos: http://ejohn.org/blog/deadly-expandos/. By default, a form element has a submit function. But, if you call any field inside your form with the name "submit" (like you do in your example), the form.submit will point to your input element and you'll not be able to submit your form.

Categories