Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-31-2012, 10:08 AM   PM User | #1
dnbmadness
New Coder

 
Join Date: Mar 2012
Posts: 20
Thanks: 3
Thanked 1 Time in 1 Post
dnbmadness is an unknown quantity at this point
Basic User Form with Back End System

Hi guys,

My knowledge on writing PHP is limited, but I'm past the beginner stage.

I need to create a form with the following data:-

First Name:
Surname:
Address Line 1:
Address Line 2:
City:
Post Code:
Country:
Date of Birth:
Interests:
Height (cm):
Chest Size (inches):
Waist Size (inches):
Inside Leg Size (inches):
Outside Leg Size (inches):
Shoe Size:
Female Dress Size:
Upload Photo:
Upload CV (pdf, doc):
Passport Present?: Yes/No
Driving License Present? Yes/No

Once this information has been submitted, it will store the info in a MySQL db, and an admin can access a back end system and view/search through candidates. It's basically a simple application form where admin's can search through users.

Is there a system out there that I could use as a stepping stone? Could someone please guide me?
dnbmadness is offline   Reply With Quote
Old 07-31-2012, 02:56 PM   PM User | #2
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
If you google your question (php form store to mysql), you'll find plenty of tutorials on how its done. PLENTY. A form is one of the most basic uses of PHP, and storing to MySQL is only a slight step further. Not saying you'll be a pro overnight, but its really easy.

The basics are as such: first you have to write proper HTML. You need to wrap everything in a form, tell it where the form goes (action attribute), and how to sent it (post or get via the method attribute). Each element of the form should have a name attribute so you know how to reference it.

Then on your processing side, you'd reference the form via the appropriate super variable (_GET or _POST), and bam, that's it for getting a form.

For example:

PHP Code:
<form method="post" action="process.php">
<
label for="firstName">First Name</label>
<
input id="firstName" type="text" name="firstName">
<
button type="submit" name="submit">Submit</button>
</
form
process.php:
PHP Code:
if (isset($_POST['submit'])) {
echo 
$_POST['firstName'];

A little googling will get you the mySQL side of the answer, and please come back and post additional questions/clarifications you have/need.
Keleth is offline   Reply With Quote
Old 07-31-2012, 08:51 PM   PM User | #3
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,667
Thanks: 46
Thanked 456 Times in 444 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Quote:
Originally Posted by Keleth View Post
process.php:
PHP Code:
if (isset($_POST['submit'])) { 
Please tell me you're not serious? - Have you seen my signature and read the topic / watched the video?

Please don't recommend using the submit button to a learner. If you're going to show them how to use isset, at least do it on a field name that will be sent such as the text field

Encouraging learners to go by the submit button is not only bad practice but also creating problems for them in the future.
__________________
Please don't be rude: Put your php code in [php][/php] tags. It is a sticky topic at the top of the forum and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Old 07-31-2012, 09:40 PM   PM User | #4
DrDOS
Senior Coder

 
Join Date: Sep 2010
Posts: 1,234
Thanks: 11
Thanked 157 Times in 157 Posts
DrDOS is infamous around these parts
You can always put this in a form for an isset statement.
PHP Code:
<input type="hidden" name="dummy" value="" /> 
If you have a bunch of pages that submit to the same $_POST, but are different, it's very handy to have one common input for the isset statement.
DrDOS is online now   Reply With Quote
Old 08-01-2012, 09:41 AM   PM User | #5
dnbmadness
New Coder

 
Join Date: Mar 2012
Posts: 20
Thanks: 3
Thanked 1 Time in 1 Post
dnbmadness is an unknown quantity at this point
Thanks kindly for your replies.

I know slightly more than that. I'm successfully able to capture the users details via POST and save their info into a db (done it yesterday), the only thing I'm stuck on is getting an image/cv uploaded which could then be retrieved in the admin backend.

Is it best practise to save the image to an upload folder and then reference the path in mysql? How would I know which image references to which user info?

Thanks so much guys.
dnbmadness is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:21 AM.


Advertisement
Log in to turn off these ads.