Updating webpage from user input - php

I've made a very simple form which one user input field and a submit button. My question is how do I get what the user has entered into the field onto the actual web page? For example if the user enters their name into the text field and hits enter, how would I get that text to show up on the web page and stay there so when the next person visits the name will show up and the next person can do the same?

To store user input for use later, you should look in to implementing a database. For some examples to get you started, check out the php documentation for mysql. The doc page for mysql_query has some basic examples to get you started:
http://www.php.net/manual/en/function.mysql-query.php

Related

save and continue form using php and mysql

anyone here knows how to make a save and continue? I have a multi page form and it have many different parts so I need a save and continue form so they can fill out this form on the other day.
So firstly a user will log in into his/her account and they will see this link,
see image here
Once they will click on it, they will see a multi page form like this,
form image
When the user has filled out these data,
Sample data,
sample data 1
sample data 2
So when the user click save, the data that the user have input will be save so when they will log in back into his/her account the data that has been saved will be displayed in the form.
Saved data,
saved data 1
saved data 2
I have not yet tried any code because I'm new to php and mysql so please help! Thank you so much.
Each time a user selects Next, add the data provided by the user to the relevant row in a database table. In this row, have a status column with status 'Draft' until the user completes the form upon which you change the status to 'Completed'.
Each time a user opens the form, load any data already entered in the past by this user.
You might consider using a column to store information about the latest page of the form used by the user, so the user can resume at that particular page of the form later.
We are not here to provide you with all the code. If you have a problem or question related to a part of the code, feel free to ask though.
Good luck!
When the user clicks on the Next Button, Save the Data into your Mysql DB in a Save Block.
In the Save block user "INSERT" Query to Insert Data to DB.
After that use PHP "header" function to redirect to the same page.

Multi-step form in Codeigniter - Redirect

I'm building a simple multi-screen form using codeigniter but I'm having some trouble working out how to keep the data and perform some tasks on each stage.
A bit of background on what it's supposed to do:
User lands on the home page with a form and fills out one field vehicle reg number.
They are then directed to another page that has pulled in their data relating to their vehicle reg number via a curl/xml request. As this web service costs per request, I only want to do this once per ip address, per day. Also, when a user refreshes the page it should not perform that call again, rather the data just be there already.
After the user is on this page, they confirm their details are correct, press next and enter their contact details.
Then they press submit and receive a confirmation message and one record is inserted into the database.
My idea for this was to record the users ip address. check the database to see if a request today had been submitted with that ip. If not, let it contiue, if so just give them a manual form to complete.
My question is how do I approach this so that when a user goes onto the next stage they have the previous data. Do I make each section a separate form that passes the previous data using hidden fields? This seems a logical way to me as I only need the data if it is a complete request. If they drop off, their data is useless to me anyway.
If i use this approach, how can I prevent the refreshing form and it trying to call via curl again?
Thanks in advance for any help.

sending data and receiving data from mysql database in the same webpage

I am trying to make a discussion board as my own project, right now I have a page where a user enter his comment, and another page where it confirms that his comment was posted, and then a third page where you could see all the comments. All this is done using php and mysql as the database that holds all the users information such as the users, name, comments, date ,etc.
What I am trying to do is instead of having three pages, I just want one page where the user enters his comment and he can see the comments right away in the same page. Can this be done, are there any good tutorials i can look at online?
You can achieve that using Ajax.

PHP putting a connection open while filling a form

A simple form to take user details but I want that if a user is already registered and if he enters his NAME then that script should search it in database and show his details in the form fields before submitting the form.
If I'm understanding you correctly you want a form where the user starts typing in his username and it will display the rest of his information automatically if his username exists in the database? Well in order to retrieve information from a database on the fly while a user is typing in the information (without refreshing the page) you will have to use Ajax.
But logically why would you want a form to search a database just based on a name and display the rest of that username's information before they have logged in or submitted the form? I think you should retrieve a user's details ONLY after you have verified who they are. Not just by them typing in a name. Maybe I am misunderstanding your question though.

How do I create a confirmation email in PHP?

I was asked by a person to create a php code, which is a part of a larger ERP software development project, so that he can test my skills. The code regarding a simple user authentication once the user registers through a form , by putting name, date of birth ,email.(which I have already done through html).
The action property of the html form, is a php file which consists of php code to get the posted inputs in the form, generate a verification link, and send it to the user via his/her email which he/she has already given.
I have two basic questions or problems:
How can this verification link be created?
Once the user clicks on this type of a link how does PHP know that they did so?
I don't think that there is any concept of event-driven programming in PHP. In that case, how does PHP handle that click and give a "conformational success message"? Is a MySQL database required or is there another easier way?
When you create the user, you are also going to generate a random string for that user. This is their authorization code. You will store it with the user's data in your database.
Then you are going to make your authorize page (ex., authorize.php). It will take a $_GET parameter of 'code', or whatever else you want (ex., authorize.php?code=theHashYouCreated). This page's code will look something like this:
if(!empty($_GET['code']))
{
/*
* Get the data from the database by the provided code.
* If a result is returned, then remove the authorization
* code from the user's record. If no user is found, then
* return an error.
*/
}
else
{
//No code was provided, so we should error.
}
Now, when the user tries to login you also want to check to see if their authorization code is set in the database. If it is, then they have not validated their e-mail address yet. If it isn't, then they have validated it.
Here's a nice tutorial that should help you create a confirmation email:
http://www.learnphponline.com/scripts/email-activation-for-php-forms
It involves creating a randomly generated activation key, that will initially be stored in the database. The key should be emailed to the user in the form of a GET parameter in a link.
Once the link is clicked, the submitted GET parameter is checked with the value in the database.

Categories