It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I am new to php. I have created a form but I am unable to understand where would this form be stored when the user presses submit. Can anyone please help me out? Thanks
<h1><a>Contact Us</a></h1>
<form id="form_317009" class="appnitro" method="post" action="">
<div class="form_description">
<h2>Contact Us</h2>
<p>Please enter the details here to get a quote.</p>
</div>
<ul >
<li id="li_1" >
<label class="description" for="element_1">Name </label>
<div>
<input id="element_1" name="element_1" class="element text medium" type="text" maxlength="255" value=""/>
</div><p class="guidelines" id="guide_1"><small>Please enter your name in it.</small></p>
</li> <li id="li_3" >
<label class="description" for="element_3">Email </label>
<div>
<input id="element_3" name="element_3" class="element text medium" type="text" maxlength="255" value=""/>
</div><p class="guidelines" id="guide_3"><small>Please Enter a valid email so we can contact back.</small></p>
</li> <li id="li_2" >
<label class="description" for="element_2">Subject </label>
<div>
<textarea id="element_2" name="element_2" class="element textarea medium"></textarea>
</div><p class="guidelines" id="guide_2"><small>Please describe the package in which you are interested so we can reach you out and give you a quote.</small></p>
</li>
<li class="buttons">
<input type="hidden" name="form_id" value="317009" />
<input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" />
</li>
</ul>
</form>
It gets stored wherever you like.
You'll need to write a php app to handle the POST HTTP request from the form, which can do something to the data: put it in a database, display it back to the user, email it, throw it away, etc.
Submitting the form sends an HTTP POST request to the URL in the action attribute.
You need to write server-side code to handle that POST; otherwise, nothing will happen.
Each form in HTML has an action attribute. Imagine the below form:
index.php
<form name="myForm" method="post" action="check.php">
<input type="text" name="username" />
<input type="submit" value="send" />
</form>
When user press submit button, your form will send to your defined address as your form action. Here, you will send your form data to check.php file.
Then depend on what was your form sending data method , you can use $_GET or $_POST in PHP to achieve the input sent data. This is an example:
check.php
<?php
$username = $_POST['username'];
echo('Welcome dear '.$username);
?>
Attention: No security issue applied in the code above and they are just a simple code to introduce you to what you need depend on your question.
The form is submitted when the button is clicked, the location it's submitted is decided by you the developer. It can go to a database, send an email, write a file, etc. you define this in the action attribute of the form tag.
Check out this reference for more information and how to get started: http://www.tizag.com/phpT/forms.php
This form would be submitted to the same page that is currently loaded (action="") and it will be stored in the $_POST array. If you want to work with this data - or store it for the future - you'll need to write code to handle the $_POST array:
<?php
if (isset($_POST)){
//do something here with the data.
}
?>
However, as soon as the page is finished loading, the $_POST array will be discarded, so if you want to do anything long-term with the data, you'll need to store it (you can do this using sessions, cookies, write the data to files, etc).
You'll want to read a lot more about this before you start working, though.
The action attribute of the form element determines what URL the data will be sent to.
In this case, as it is empty, the page will post to itself.
You need to have server side code to capture and store this data, otherwise it will be lost.
As for where it will be stored - that is up to you. You can save to a file, a database, send it by email or sms or even just ignore it.
Its better to think off the data less stored more posted and can be retrieved with
$_POST['guide_1'];
To store the data you would have to retrive the post and then store it some where your self
Also a good link to get and post in php is http://www.tizag.com/phpT/postget.php
Related
Basic question. If I have a form in my HTML (where in my case someone inputs a date), how can I have my users cause a GET request with the contents of that form instead of a POST.
e.g. form entry (e.g date)... so 20190312
what I am trying to achieve is such that AFTER the user submits the form.. the user is the lead to page that has
GET domain.tld/scriptname.php?variable=20190312
and then the system then processes the GET request accordingly.
thank you
Maybe i'm missunderstanding what you are asking.
This can easly be achived using builtin GET method in FORM tag
<body>
<form id="form" method="GET" action="scriptname.php">
<input id="date-txt" type="text" name="date">
<input id="search-btn" type="submit" value="Submit">
</form>
</body>
While filling up above field ad clicking "Submit" form will be submitted and you can see in your url path/or/page/scriptname.php?date=INPUT_FIELD_VAL
for every input in #form with a name, if GET method is used, you'll see a ?name=value in the url
What you describe is the default behaviour of a form. If you don't want a POST request, then don't use a method attribute to set the request type to POST.
<form action="//domain.tld/scriptname.php">
<input name="variable" value="20190312">
<button>Submit</button>
</form>
Hey guys i have a question. I am trying to set up something for my insurance website. I want to setup a capture page where the user inputs everything related to their vehicle and their information and once they click submit and proceed it directs them to another page of mine where it autopopulates all this information and gives them a quote. My question is how could i go about doing this?
The most simple solution is to use a Form on one page, that'll be submitted to another page, where the data will be processed and populated.
you can find many examples on the internet.
here's a good example from PHP's DOCS - Dealing With Forms:
HTML form:
<form action="action.php" method="post">
<p>Your name: <input type="text" name="name" /></p>
<p>Your age: <input type="text" name="age" /></p>
<p><input type="submit" /></p>
</form>
and action.php file, where the data will be handled:
Hi <?php echo htmlspecialchars($_POST['name']); ?>.
You are <?php echo (int)$_POST['age']; ?> years old.
you can see that any information sent with a form via the POST method, can be captured in the target php file using the the $_POST variable (a SuperGlobal).
I've been working on having a form where a user can input a subreddits name in a input form and be taken to it, but not been working out well. I've tried using get and name="q" but it makes the address funky.
What I have so far:
<form method="post" action="http://www.reddit.com/r/" style="margin-left:5px;margin-right:5px;margin-bottom:0px;">
<input class="form-control" value="" placeholder="Subreddit Name">
</form>
If you're not getting what i'm trying to do: A user types text into an input, the text they typed would be sent to an address as reddit.com/r/(whatever the user typed)
Not knowing from your question whether or not you have access to server-side coding, and based on your answers in the comments, the following should work for you. Note that if a browser has JavaScript disabled, this will bring the user directly to http://www.redit.com/r/
If you have access to server-side scripting, you could add a catch on your server as well to avoid this.
<form method="post" onsubmit="document.location='http://www.reddit.com/r/'+document.getElementById('subredditname').value;return false;" action="http://www.reddit.com/r/" style="margin-left:5px;margin-right:5px;margin-bottom:0px;">
<input id="subredditname" class="form-control" value="" placeholder="Subreddit Name">
</form>
You can do this easily with PHP.
User types text into input field
<input type="text" name="user_text" />
After form submit, run PHP code
$page = $_POST['user_text'];
//send user to website
header('Location: http://reddit.com/r/' . $page);
Here is my "form" http://www.confidentialpatient.com/js/index.html
I need to add a few things to this:
The person, once finished adding "items," clicks "NEXT"
On the next page, a summary of the items selected on the previous page is given (in a list format). Basically, this is a confirmation page
They are then able to click "SUBMIT," in which this form data is emailed to me.
I know this might be a lot, but I'd greatly appreciate any insight!
You can not do this without a server-side scripting language. The few choices you have are PHP, ASP.NET, PERL or Python.
For your reference, I have mentioned a test script along with PHP code to submit a form with only one field and then receive that information on the next page and then display it to the user in an h2 tag.
Code for page 1:
<form method="post" action="page2.html">
<h1>This is a test form</h1>
<label>Enter your full name</label>
<input type="text" name="fullname" />
<input type="submit" name="submit" value="Submit Form" />
</form>
Code for page 2 (Receiving page):
<?php
$name = $_POST['fullname'];
?>
<h2>You submitted name is: <?php echo $name; ?> </h2>
I want visitors to my website to be able to search for airport lounges offered by a company called Priority Pass. I have created the following form:
<form action="http://prioritypass.com/lounges/lounge-print.cfm" method="post">
<input type="text" id="print_airport_code" name="print_airport_code" value="MAN" />
<input type="submit" value="Submit" />
</form>
Which mirrors the form they have on their own mobile search site (here). But when I submit my form it doesnt seem like the parameters are being posted properly.
Any help would be great. Thanks.
The form on their website doesnt appear to contain any fields which I have missed?
You're pointing to the wrong URL; POSTing to /lounges/lounge-print.cfm is producing an HTTP redirect header, which is corrupting your output.
Additionally, the name of your input field is incorrect. Using someone else's form results often requires you to maintain all field names consistently as they appear on the remote site.
Change the form to:
<form action="http://www.prioritypass.com/mobile/lounges.cfm" method="post">
<input id="Airport_Code" name="Airport_Code" type="text" size="10" value="MAN" />
<input type="submit" value="Submit" />
</form>