The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> What happens to form entries?
Forca
post Nov 25 2016, 02:19 PM
Post #1


Novice
**

Group: Members
Posts: 26
Joined: 29-April 16
Member No.: 24,203



Hi

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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Nov 25 2016, 02:31 PM
Post #2


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,546
Joined: 9-August 06
Member No.: 6



You point the form to your script using the action attribute.
http://htmlhelp.com/reference/html40/forms/form.html

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.


User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Nov 25 2016, 03:58 PM
Post #3


.
********

Group: WDG Moderators
Posts: 7,530
Joined: 10-August 06
Member No.: 7



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

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

See http://php.net/manual/en/tutorial.forms.php

The PHP script must sanitize the form input to prevent SQL injections. Nowadays PDO or MySQLi are recommended, but I have no personal experience:
http://php.net/manual/en/security.database.sql-injection.php
http://php.net/manual/en/pdo.prepared-statements.php
http://php.net/manual/en/mysqli.quickstart...-statements.php

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



User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Forca
post Jan 3 2017, 02:49 PM
Post #4


Novice
**

Group: Members
Posts: 26
Joined: 29-April 16
Member No.: 24,203



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">
<div1>
username: <input type="text" id="name" name="user_name" />
</div>

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

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?

Thanks.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Jan 3 2017, 03:12 PM
Post #5


.
********

Group: WDG Moderators
Posts: 7,530
Joined: 10-August 06
Member No.: 7



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:

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

See also http://www.w3.org/TR/2014/REC-html5-201410...-user-interface
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jan 3 2017, 03:15 PM
Post #6


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,546
Joined: 9-August 06
Member No.: 6



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jan 3 2017, 03:16 PM
Post #7


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,546
Joined: 9-August 06
Member No.: 6



Beaten by Christian again. sad.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Forca
post Jan 3 2017, 06:53 PM
Post #8


Novice
**

Group: Members
Posts: 26
Joined: 29-April 16
Member No.: 24,203



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 23rd April 2017 - 12:53 PM