Help - Search - Members - Calendar
Full Version: What happens to form entries?
HTMLHelp Forums > Web Authoring > Web Site Functionality

I have setup a customer registration webpage for my customers using forms. What happens to the info entered into these forms? Same as the name, address, password, etc.?

Ultimately I need to write a script that takes this info entered and puts them into a MySQL database which I am working on. Server side scripting language supported by my webhost is PHP. I have a good grasp of MySQL but have never used PHP. So am curious as to where PHP will pickup the info entered in the registration form.

Also, can anyone point me in the direction of any online PHP code that does this already that I wish to achieve. I would not like to reinvent the wheel.

Many thanks.
You point the form to your script using the action attribute.

If there is no action attribute or if it's empty the form is submitted to the current page. If that doesn't happen to have a script embedded designed to handle the form, nothing much happens. The page reloads and nothing is done with the form data.

Christian J
QUOTE(Forca @ Nov 25 2016, 08:19 PM) *

am curious as to where PHP will pickup the info entered in the registration form.


The PHP script must sanitize the form input to prevent SQL injections. Nowadays PDO or MySQLi are recommended, but I have no personal experience:

There are many readymade scripts on the web, but they might be of varying quality security-wise.

Thanks pandy, Christian. I have been learning PHP and am now dealing with PHP scripts and the HTML Form element. I have come across two Form elements and wonder which to use and why there is a difference.

<form action="/my-handling-form-page" method="post">
username: <input type="text" id="name" name="user_name" />

<label for="name"> password: </label>
<input type="text" id="name" name="user_name" />

div1 seems to throw in the label in the same line as the input definition whilst div2 has the label as it's own element. This allows me to style the label as well. Why the difference and how do you style the label in div1?

Christian J
In the first DIV the label text "username" is just loose text. You might style it through the DIV element, but that will of course affect the INPUT element too. There's no reason to use this first example, unless you want to save typing for some reason.

The second DIV uses the LABEL element, which both makes the label text easier to style and makes the form's HTML structure richer. Note that you can also put the INPUT inside LABEL, which lets you leave out the FOR and ID attributes, but instead styling becomes trickier unless you use e.g. a SPAN element around the label text:

<label><span>password:</span> <input type="text" name="user_name" /></label>

See also
It's a difference because in case two you packet the label text in an element. In case one it's just loose text.

There is no such things as DIV1 and DIV2. You can't invent your own elements. If you need to distinguish between them you can use a class or an id.

There isn't any need to put each input in its own DIV either.
Beaten by Christian again. sad.gif
Thank you. I made it div1 and div2 simply for ease of reference for this post. Otherwise they are just div in my code.

Also, I put each input in its own div to make styling easier. Particularly the spacing between the inputs. If there is a better way then I'm all ears.

Thanks again.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2018 Invision Power Services, Inc.