form help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
flybyknight
Forum Newbie
Posts: 3
Joined: Tue Nov 30, 2010 7:49 pm

form help

Post by flybyknight »

Moved to PHP Code forum by moderator.
I building some simple form pages for a small project.
I have the register, login, and forms pages created that I need.
The forms put data into a table on a mysql database.

What I need help with is getting some fields to auto populate.
Simplified Example:
I have a user "bob" .
He is a registered user.
He logs in.
He is then redirected to a form page.
I want his name to already be in the approriate field on the form.
He fills out the other required fields and submits the form, which updates fields on another table.
I need to beable to pull up a table that shows bob filled out the form on a given date and have his field info as well.
Anyone?
Thank You
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: form help

Post by califdon »

These references should help you understand how to do this with PHP and MySQL:
http://phpsense.com/php/php-login-script.html
http://www.phpcatalyst.com/php-scripts/ ... script.php
http://www.knowledgesutra.com/forums/to ... -tutorial/

You can find many more by going to Google.com and entering in the Search box:
php login script tutorial
flybyknight
Forum Newbie
Posts: 3
Joined: Tue Nov 30, 2010 7:49 pm

Re: form help

Post by flybyknight »

Thank You,
But I have the register and login pages already working.
What I can't seem to figure out is how to get the user information to display in the next form page after you have logged in..
I'm trying to avoid the user having to put his name and address in every page.
Once you are logged in, it would just populate the approriate fields with your user information and you could continue filling out the rest of the form.
I hope I'm making sense.
Thanks
smashhell
Forum Newbie
Posts: 14
Joined: Fri May 22, 2009 2:54 am

Re: form help

Post by smashhell »

flybyknight wrote:Thank You,
But I have the register and login pages already working.
What I can't seem to figure out is how to get the user information to display in the next form page after you have logged in..
I'm trying to avoid the user having to put his name and address in every page.
Once you are logged in, it would just populate the approriate fields with your user information and you could continue filling out the rest of the form.
I hope I'm making sense.
Thanks
That is actually not too hard.
You just have to store the user's information somewhere, either in a database or cookie or sessions.
Than withdraw them on any pages that needed the information.
than just echo the appropriate values into each form.
flybyknight
Forum Newbie
Posts: 3
Joined: Tue Nov 30, 2010 7:49 pm

Re: form help

Post by flybyknight »

I have the information stored in a mysql database.
The login info is being stored in a table.
I have the next form pages also storing the data in the same database to a seperate table.
I can bind the form to the database.
What I can't figure out is how to get the logged in users data to come up in the next form.
I could post it to the next form, but it would be better if it pulled it from the user data in mysql.
It should be pretty simple. A shopping cart does that. I just can't figure out how to retrieve only the users data and put it in the correct fields.

If anyone knows of a place with a sample code for this would be great.

Thanks
anandgodar
Forum Newbie
Posts: 3
Joined: Thu Dec 09, 2010 5:23 am
Location: Nepal

Re: form help

Post by anandgodar »

ok i have a refrence this may help you
http://www.phpfresher.com
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: form help

Post by califdon »

flybyknight wrote:I have the information stored in a mysql database.
The login info is being stored in a table.
I have the next form pages also storing the data in the same database to a seperate table.
I can bind the form to the database.
What I can't figure out is how to get the logged in users data to come up in the next form.
I could post it to the next form, but it would be better if it pulled it from the user data in mysql.
It should be pretty simple. A shopping cart does that. I just can't figure out how to retrieve only the users data and put it in the correct fields.

If anyone knows of a place with a sample code for this would be great.

Thanks
If I understand what you described, you're on the wrong track. It sounds like you are storing the same data redundantly--a massively bad thing to do. Login operations should reference a single table that stores data on registered users, but it should not be stored anywhere else.

You need to understand what a session is. This is what enables you to temporarily store data on the server while a user is still browsing your website. Use Google to search for php session. There you will find literally hundreds of code examples and explanations.
anandgodar
Forum Newbie
Posts: 3
Joined: Thu Dec 09, 2010 5:23 am
Location: Nepal

Re: form help

Post by anandgodar »

First store the variable name in the session and display in its appropriate position .http://www.phpfresher.com
Post Reply