why my forms are not working in bootstrap website? - php

I tried all but no form is working with method or simple action like http://google.com `
<form action="http://google.com" method="post">
<input type="text" />
<input type="submit" />
</form>
even this is not working

use this
<form role="form" action="http://google.com" method="post">
<input type="text" name="text" />
<input type="submit" name="submit" />
</form>
role attribute for FORM
name attribute for input

In PHP, $_POST always accept name attribute from form elements:-
You need to write
<input type="text" name='name_of_your_field' />
instead of
<input type="text" />
You need to refer this Link.

Related

How to post html outside your domain?

Let's say we are making a form that we want to have on domain1.com and we want to post it to domain2.com. Can this be done?
<form method="post" action="domain2.com/receivepost.php">
<input type="text" name"text" />
<input type="submit value="submit" />
</form>
domain2.com/receivepost.php
<?php print_r($_POST); ?>
You need to specify the full URL (including protocol) in the action attribute of your form tag as follows:
<form method="post" action="http://domain2.com/receivepost.php">
<input type="text" name="text" />
<input type="submit" value="submit" />
</form>
On the PHP side, you can check for POST data as follows:
if (isset($_POST['text'])) {
echo $_POST['text'];
}
Notice that the name attribute of the input tag is text.
You need to specify full URL if you want to send request to specific domain
<form method="post" action="http://domain2.com/receivepost.php">
<input type="text" name"text" />
<input type="submit value="submit" />
</form>
Or you can send to relative (for your domain) path:
<form method="post" action="receivepost.php">
<input type="text" name"text" />
<input type="submit value="submit" />
</form>

form action, send data from the current form in the URL

for the life of me cant remember how i should be doing this / if its possible.
I am creating a form that takes the user to another page but want to pass the value of the text box in the url.
so e.g:
<form action="newadvert.php?vrm=" class="newadvertform" method="post">
<input type="text" name="carvrm" class="carvrm"/>
<input type="submit" class="newadvertsubmit" value="Create Advert" />
</form>
How can i send the user to newadvert.php?vrm= THE ENTERED TEXT HERE
I need this to then get value on the next page.
Use GET method
<form action="newadvert.php" class="newadvertform" method="GET">
And rename carvrm to vrm
<input type="text" name="vrm" class="carvrm"/>
Use the GET method and rename carvrm to vrm.
<form action="newadvert.php" class="newadvertform" method="GET">
<input type="text" name="vrm" class="carvrm"/>
<input type="submit" class="newadvertsubmit" value="Create Advert" />
</form>
When submitting the form, it'll go as http:///newadvert.php?vrm=
<form action="newadvert.php" class="newadvertform" method="get">
<input type="text" name="vrm" class="carvrm"/>
<input type="submit" class="newadvertsubmit" value="Create Advert" />
</form>
change your form method from post to get
Like this:
<form action="newadvert.php" class="newadvertform" method="get">
<input type="text" name="carvrm" class="carvrm"/>
<input type="submit" class="newadvertsubmit" value="Create Advert" />
</form>
you can get input value by :
$_REQUEST['carvrm']
or change input name to vrm :
<form action="newadvert.php" class="newadvertform" method="get">
<input type="text" name="vrm" class="carvrm"/>
<input type="submit" class="newadvertsubmit" value="Create Advert" />
</form>
now you can get input value by :
$_REQUEST['vrm']
doc: http://www.w3schools.com/PHP/php_forms.asp

PHP Send query string with button

I have a form for searching products which will be visible in each page. When the search button is clicked it will redirect to a search.php page. I want to send a query string (parameter) with the content of the search text box when the button is clicked. The code for the form is simple, but here it is:
<form method="post" action="search.php">
<input type="text" id="txtSearch" name="txtSearch" class="searchInput" value="" />
<input type="submit" id="btnSubmit" name="btnSubmit" value="Search" ?>'" />
</form>
I want that when clicked this will redirect to search.php?q=txtSearch. Thanks.
Change "POST" to "GET" on the form element and change the input name parameter to "q".
use :
<form method="get" action="search.php">
<input type="text" id="txtSearch" name="q" class="searchInput" value="" />
<input type="submit" id="btnSubmit" name="btnSubmit" value="Search" />
</form>
<form method="post" action="search.php?q=txtSearch">
<input type="text" id="txtSearch" name="txtSearch" class="searchInput" value="" />
<input type="submit" id="btnSubmit" name="btnSubmit" value="Search" />
</form>
This way submitting the form you'll be redirect to search.php?q=txtSearch and from php you can get the $_POST variable so
$_POST['txtSearch']
$_POST['btnSubmit']
Just use GET instead of POST
<form method="get" action="search.php">
The name of the fields will be the name of the querystring variable. Like this:
?input_name=input_value

Why is this form making the fields and variables part of the process form?

I am doing this:
<form action="processform.php" type="post">
<input type="text" name="sample">
<input type="text" name="how">
<input type="checkbox" name="fields" value="fields">Something</input>
</form>
When the submit button is hit, this is what shows in the address bar of the process page:
https://www.domain.com/processform.php?sample=&how=&fields=
Change to <form method="post" />
change type="post" to method="post" for starters
The method attribute specifies the submission type (e.g. "get" or "post"), but you've used the type attribute...and this is incorrect. You need something like:
<form action="processform.php" method="post">
<input type="text" name="sample">
<input type="text" name="how">
<input type="checkbox" name="fields" value="fields">Something</input>
</form>
Your markup is wrong
Try
<form action="processform.php" method="post">
<input type="text" name="sample" value='VALUE' />
<input type="text" name="how" value='VALUE' />
<label for='fields'>Something</label>
<input id='fields' type="checkbox" name="fields" value="Something" />
</form>
<form action="processform.php" method="post">
type needs to be method

PHP/HTML form submission

I have the HTML and PHP code
<form name="addaserver" method="post" action="addaserver.php">
<p>Server Name<form method="post">
<input name="servername" type="text" /></form>
<p>Description<form method="post">
<input name="description" type="text" /></form>
<p>Server IP<form method="post">
<input name="ip" type="text" /></form>
<p>Tags (ex: "pvp, economy, fun")<form method="post">
<input name="tags" type="text" /></form>
<form method="post">
<input name="submitserver" type="submit" value="submit" /></form>
</p>
and
(addaserver.php)
$servername=$_POST['servername'];
$desc=$_POST['description'];
$ip=$_POST['ip'];
$tags=$_POST['tags'];
Obviously I'm trying to get the data from the forms...however when I click "submit" it just reloads the page the forms are on. It's probably just some simple error, but I can't figure out what's wrong D:
You're supposed to define only one form, not one for each input:
<form name="addaserver" method="post" action="addaserver.php">
inputs, inputs, inputs, submit
</form>
First thing I see wrong is that you have two separate form tags in the same HTML.
The second one is pretty much useless as it provides no data to any target or action. I would restructure your HTML to be more like this and try it;
<form name="addaserver" method="post" action="addaserver.php">
<p>Server Name<form method="post">
<input name="servername" type="text" /></p>
<p>Description<form method="post">
<input name="description" type="text" /></p>
<p>Server IP<form method="post">
<input name="ip" type="text" /></p>
<p>Tags (ex: "pvp, economy, fun")
<input name="tags" type="text" /></p>
<p><input name="submitserver" type="submit" value="submit" /></p>
</form>
Also take note of the fact that I got rid of all your closing form tags as they would have caused issues too. You only need one closing tag at the very outside most segment of your form's body as shown in the code sample too.
You have way too many <form method="post"> tags in your code.
Your code should start with <form method="post"> and end with </form>, but in between there should only be input fields.
You define action to 'addaserver.php' in the first <form> tag, but the submission button is after a different <form> tag so it doesn't respect that initial target you are setting.
You seem to be enclosing all your input element in different tags. a Form tag is a collection of Form elements that will have their values submitted when the form is submitted. And if you do not specify the action attribute on a form it will (as you say) reload the page. So in the above example if you remove all the tags surrounding the input tags and put them all under the same tag you should get your information posted
Look at http://www.w3schools.com/html/html_forms.asp and http://www.tizag.com/phpT/examples/formex.php for examples on how to do this.
Hope that makes sense.
You only need one form tag for the whole form to submit
<form name="addaserver" method="post" action="addaserver.php">
<p>Server Name
<input name="servername" type="text" /></p>
<p>Description
<input name="description" type="text" /></p>
<p>Server IP<form method="post">
<input name="ip" type="text" /></p>
<p>Tags (ex: "pvp, economy, fun")
<input name="tags" type="text" />
<input name="submitserver" type="submit" value="submit" /></form>
</p>
You're nesting extra form tags throughout your form. You only need one form tag. All of the inputs go inside it.
<form name="addaserver" method="post" action="addaserver.php">
<p>Server Name</p>
<input name="servername" type="text" />
<p>Description<</p>
<input name="description" type="text" />
<p>Server IP</p>
<input name="ip" type="text" />
<p>Tags (ex: "pvp, economy, fun")</p>
<input name="tags" type="text" />
<input name="submitserver" type="submit" value="submit" />
</form>
Try this instead:
<form name="addaserver" method="post" action="addaserver.php">
<p>Server Name: <input name="servername" type="text" /></p>
<p>Description: <input name="description" type="text" /></p>
<p>Server IP: <input name="ip" type="text" /></p>
<p>Tags (ex: "pvp, economy, fun")<input name="tags" type="text" /></p>
<p><input name="submitserver" type="submit" value="submit" /></p>
</form>

Categories