data calling from one page to another? - mysql

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).

Related

Occasional Failure of a HTML Form

I have what I think is a pretty simple form for filling in a couple of dates and sending the user to another page. Unfortunately I find that occasionally the data is not passed to the new page, although the user does get to the page.
The code of my form is
<form action="/book/book1.php" method="post" target="_blank" id="bookboxform" name="bookboxform">
<input name="hid" type="hidden" value="<?php echo $hid ?>">
<!-- This next line added to provide an alternative identification of the hotel -->
<input name="hotelname" type="hidden" value="<?php echo $row_hotel['hotel'] ?>">
<input type="text" name="ArrivalDate" id="ArrivalDate" value="" placeholder="Loading.... please wait" readonly>
<input type="text" name="DepartureDate" id="DepartureDate" value="" placeholder="Loading.... please wait" readonly>
<input type="submit" class="button" value="Click Here!">
</form>
The two date inputs use Jquery UI to provide a selectable calendar.
In the second page (book1.php) I use
if(empty($hid) {
to send me an email of the form has failed. This tells me the user-agent.
Generally it seems to be iPhones and iPads that are usually failing, though most others have done it at some time. I estimate it's happening in 2-5% of occasions when someone tries to use the form. What could be causing this random failure?
It would appear that the failures were caused by users copying the url of book1.php and then pasting it into a fresh browser tab. As the data was being passed by POST method, the data was lost. I am now using GET method so the data is a part of the url, and there have been no failures since.

Input text to link with a form?

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);

How to display the data in a 'form' to a new webpage with tables for the respective form data?

I have designed a form page with some user fields...the data collected on the form can be mailed to a website or an email id...but I dunno how to display the data on another web-page that I have created(in offline mode currently).
Html
<form action="welcome.php" method="post">
Name: <input type="text" name="name">
Age: <input type="text" name="age">
<input type="submit">
</form>
remote file welcome.php
<?php echo $_POST["name"]; ?>
<?php echo $_POST["age"]; ?>
You can save a webpage as a .php file, and this can be mostly html with some php included in it.
This way you can use post or get from your form submit, and recieve the information on another page and do something with it.
Form submission: http://w3schools.com/php/php_forms.asp
Post: http://w3schools.com/php/php_post.asp
Get: http://w3schools.com/php/php_get.asp
With the information given this will point you in the right direction, and might be a useful learning resource, if you have any problems after looking through the information, edit in you're attempt and I'll help some more.

Need to add submit button that will email the form's data to me

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>

Where are webform data stored? [closed]

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