What I want to achieve is the following. A search is made from one IFrame "the form is loaded into this frame via the src atribute of iframe" the search query is then passed to another IFrame that redirects to a url with the query eg. www.test.com/index.php?query=test
Is this possible?
Currently my code looks as such
<iframe src="abc.php" name="iframe1">
</iframe>
<iframe name="iframe2">
<?php
var_dump($_GET);
?>
</iframe>
abc.php contains the following
<form method="get" action="#" target="iframe2">
<input type="text" name="searchtype" id="searchtype" />
<input type="submit" value="submit">
</form>
Untested (don't have PHP installed on this machine).
You are passing your submission form back to itself, and loading the result into iframe2, which is why you just see that form again in the other frame. So what you need to do is put your form processing logic into a second .php file, instead of inside your iframe tags, and then have the form's action be abcd.php (or whatever) and keep the target as iframe2.
Try this.
<form method="get" action="<?php $_SERVER['PHP_SELF']?>" target="iframe2">
<input type="text" name="searchtype" id="searchtype" />
<input type="submit" value="submit">
</form>
Related
So as usually I put in information in the url leading towards another page like this:
<form action="index.php?type=question">
<input class="log-btn extra" type="submit" value="Home">
</form>
Usually it always works, I even copy pasted it because I've used the exact same url before and on the other page it works but doesn't on this one it just returns empty after the questionmark like this:
index.php?
When you want to misuse a Button as a link with URL query parameters you can do it in two ways.
In your example you try to set query parameters in the action attribute of the form. That is working as long as the method is not get, because get-parameters and URL query is exactly the same thing and submitting the form will overwrite the query with the get parameters of the form elements.
<form action="home.php?type=question" method="post">
<input class="log-btn extra" type="submit" value="Home">
</form>
You can also set <form method="get"> and use a button:
<form action="home.php" method="get">
<button type="submit" name="type" value="question">Home</button>
</form>
I can only use php and html to do this.
I'm trying to pass the input of a text box to the URL. Something like this ?input=
The page will be the same.
<form method='post' action="">
<input type="text" name="input">
</form>
If you want the values to be in the url you need to change the method of your form to get
<form method="get" action="">
This will cause your url to look something like http://mydomain.com/index.php?input=something. All values passed in the URL like this are then accessible via $_GET.
<?PHP
echo $_GET['input'];
?>
You don't need the anchor tag as you have it. Just changing the form will cause the form to submit as you want it.
<form method='get' action="">
<input type="text" name="input">
<input type="submit" value="Submit">
</form>
if you wanted to append all form input in the url then you should use get form method.
and you should not use anchor tag because it seems that it is meaningless.
So your form should be like this:
<form method='get' action="">
<input type="text" name="input">
<input type="submit" value="Submit">
</form>
After submitting the form you will url like this:
http://yousite.com/this_page?input=typed_value
you can access your purl params by using global $_GET or $_REQUEST (e.g $_REQUEST['input'])
I have a problem with creating a simple search form, used to search my database.
I started using the POST-method and everything worked fine, but switched to using GET-method instead to be able to bookmark my search results. But now I have trouble with the "action-url" when posting.
<form action="index.php?page=searchresult'" method="post">
This worked fine, I got my var's sent to the stated URL, but
<form action="index.php?page=searchresult" method="get">
Doesn't work. When I check my HTML code everything looks great, but I end up going to the URL
site.com/index.php?ALL THE GET-variables linedup here.
I am loosing the "?page=searchresult" part when using the GET-method?!
Am I missing something here, please help?!
Humble regards :)
Try changing this to
<form action="index.php?page=searchresult" method="get">
Put the page element as a hidden tag.
<form action="index.php" method="get">
<input type="hidden" name="page" value="searchresult"/>
<!-- Rest of the input elements -->
<input type="submit" />
</form>
This should fix your issue.
If you are using GET methood then you can pass page parameter in hidden field
like
<input type="hidden" name="page" value="searchresult">
GET sends data in the query string. If the URL in the action has a query string, it will be overwritten by the new one generated by the form.
Store your data in hidden inputs instead.
Well, this is interesting, but you can fix it using an hidden <input>, such as this:
<form action="index.php" method="get">
<input type="hidden" name="page" value="searchresult" />
<input type="submit" value="submit" />
</form>
Just compile the "value" of the hidden input with what you need to pass.
Tried it and it actually works.
Edit:
obviously, from php, use this:
<?php $page = ((isset($_GET['page'])?($_GET['page']):("nope")); ?>
Add a hidden page data in the form.
<form action="index.php" method="get">
<input type="hidden" name="page" value="searchresult" />
Simply because "page=searchresult" is a get data.
You have a quote too much, try removing it.
|
\|/
<form action="index.php?page=searchresult'" method="post">
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
Do anyone know how can I rewrite a URL in php for the submit action?
Example:
I have a code as following:
I call to the page by using the following link www.assignment.com (I have set the index to test.php) and test.php will display the following code.
<form action="test.php" method="post">
<input type="text" name="phone" value="">
<input class="submit_btn" type="submit" name="submit" id="submit" value="SUBMIT">
</form>
when I clicked on the submit button, it will post to test.php to do the action and the display the same input page. However once submit button been clicked, the url link will become www.assignment.com/test.php. any way that I can rewrite the url to www.assignment.com after submit instead of www.assignment.com/test.php?
If your test.php is run when http://assignment.com/ is loaded, you could just change the form target to:
<form action="/" method="post">
You could use header("Location: www.assignment.com"); at the end of your test.php script.