I'm trying to display user entered value in form A to be part of the url of page B. For example:
Form A:
<form method="post" action="display_annotation_for_pdbid.php" target="_parent">
<fonttdresult><b>Search Database by PDB ID:</b><br/></fonttdresult>
<input type="text" name="pdbid" id="pdbid" placeholder="Enter a PDB ID" style="width:
106px;">
<input type="submit" name="submit" value="Submit">
</form>
So instead of displaying the new page url as display_annotation_for_pdbid, I want it to display something like 'display_annotation?StructureID:1y26' when the user enters 1y26 in form A. Can someone help me with this?
if you use GET method iin your form to post data , variables will automaticlly be placed in URL
Create another file display_annotation_for_pdbid.php which will contain code to redirect to required url. Try below code
display_annotation_for_pdbid.php
<?php
$pdbid = $_POST['pdbid'];
header("Location : display_annotation.php?StructureID=".$pdbid);
?>
Related
I have created a form with a search button above it.
I write something in the search box and submit it but it returns to web/index?search='something'.
I want it to return to where I am now. I mean, index and I use the following code:
<form action="<?=Yii::$app->homeUrl?>?r=phone/index">
<input type="text" name="search" placeholder="Search..">
<input type="submit">
</form>
phone is my controller and index is the page I have my form in.
Thanks
homeUrl will send you to where you've configured it or to it's the default location if you haven't. Try this if you want to send the form data to the same URL where the form is:
yii\helpers\Url::to();
Change
"<?=Yii::$app->homeUrl?>?r=phone/index"
By:
"<?=\yii\helpers\Url::to(['phone/index'])?>"
I want to create a simple PHP website were user should enter any string in text box and click submit then that string should be placed in the URL
For example:
If user entered "Java" as their input then after clicking submit, the URL should change to:
example.com/Java
How it's possible any example or a sample program if possible
Well, taking your question literally, this should work
<?php
if(isset($_POST['submit'])){
$userInput = $_POST['userInput'];
header('Location:example.com/'.$userInput);
}
?>
<form action="" method="POST">
<input type="text" name="userInput"/>
<input type="submit" name="submit" value="Send"/>
</form>
Of course, depending on your codes, this might be used to tamper or do something bad to your codes.
I have created 3 php pages. The 1st includes the following form:
<form method="POST" name="go" action="search_form_all.php" >
<input name="value" type="text" id="search_form_1" size="65" placeholder="enter name"/>
<input type="submit" value="" name="submit" />
</form>
The 2nd page called "search_form_all.php" includes the php codes that displays the results of the above form. So if the user type a name in form and press submit, the "search_form_all.php" displays all names from my database according to what the user inserts in the search form.
All I want is to have in my 3rd php page a link, that when the user press it to execute the form in 1st page. For example if I enter a name in search form like "john", then I want to be able to go to my third page and press the link, the form to be executed and to return all names "john" from my database. Is this possible?
Yes, this is possible with session variables. An example:
<?php
session_start();
if(isset($_SESSION['views'])) {
$_SESSION['views']=$_SESSION['views'];
} else {
$_SESSION['views']=1;
}
echo "Views=". $_SESSION['views'];
?>
You can also refer to Document Link
Let me know if you need more help.
I am looking for a bit of code to do the following:
A form containing a single text field and a submit button, must send the value of the text field to a landing page that automatically counts how many html tags that this page contains.
E.g. if the text field states stackoverflow.com, the landing page should say (H1 tags = 20) with many more parameters to come.
How is this done? I know how to make a form, but I do not know how to make it send its value to the landing page.
<form action="landingpage.php/" method="post">
The URL
<input type="text" name="cf_name">
<input type="submit" value="Submit">
</form>
This piece of code is a perfect answer to your question.
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET">
Type In Something: <input name="random-info" type="text" size="25">
<input type="submit" value="Submit">
</form> <br>
<?php
echo "You Typed: " . $_GET['random-info'];
?>
you get the method into the url, then you can use them on another page.
To access data from a form it depends on the method. Since your code shows a post message you simply access it in the php on the landing page by user $POST_['cf_name'].
To learn more you can check out:
http://w3schools.com/php/php_post.asp about the post method and http://w3schools.com/php/php_get.asp about the get method.
Also an invaluable source is php manual itself.
As far as counting the tags, not really sure what you are trying to achieve.
If you are counting the tags in the page you create, just make a variable and add to it each time you put that specific tag on the page.
Then you can put those values in a hidden field of the form to be passed into your landing page.
I'm working on a site that gives the users of the site pre-written letters to send to places. All the user has to do is fill out a form and hit continue, then whatever information the user put into the form (like name for example) gets plugged into a pre-written letter on a printable page. A basic example would be if the form asks for Name then you hit continue, on the printable page, it would say:
Hi, my name is Zach.
I'm using a php based content management system so it should be in php. I know this is a very simple thing to do for those who know how to do it, I unfortunately don't. Thank you in advance for your help!
Suppose you have this form:
<form action="preview.php" method="POST" >
<input type="text" name="name" />
<input type="submit" value"Print" />
</form>
When you hit submit, the values of all the fields (input in this case, but also textarea, selects, etc) are save to the POST array (or GET if you set method="GET").
You access the POST and GET arrays from the preview.php page (where you want to print the name in this example) with code like this:
<?php
$name = $_POST['name'];
?>
<p>Hi, my name is <strong><?=$name?></strong>.</p>
in your first page:
<form action="letter.php" method="get">
<input type="text" name="personsName"></input>
<input type="submit" value="submit">
</form>
Then in letter.php do this:
<?php
$firstname = $_GET['personsName'];
echo "My Name is" .$firstname;
?>
That ok? :)