Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Registration

Guest
Jan 14, 2007 Jan 14, 2007
I am new to the PHP world and as I am developing for friends and family I get questions on can certain functions be done and one has come to me recently which I do not know how to structure.

As you know my heading talks about registration.

I have already developed where someone can register by placing their name, address, phone number and e-mail. However, now it is going a little further which I do not know what is the structure for PHP and MySQL.

For example, I know if I wanted a name field it is a VARCHAR in MySQL, and if I wanted a yes or no I can use a checkbox field and that would by a tinyint in MySQL. The confusion for me is how do I set up the database for when you see registration where they ask for what is your favorite sports and there is a list of checkboxes and at the bottom there is a check box that says all and some how you see the checkbox has a check mark in all the boxes. How is this set up within PHP or I guess it will be HTML form tag. What I do not understand is what is the structure that if you have more than one checkbox which can be different interests, how does that get applied to the database of MySQL, is it a VARCHAR, or INT or even LONGTEXT? How does this get setup for registration applications? This is where I need guidance.

Can someone guide me in this, it is greatly appreciated.

Thank you,
AdonaiEchad
TOPICS
Server side applications
288
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 15, 2007 Jan 15, 2007
No body knows?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 15, 2007 Jan 15, 2007
LATEST
AdonaiEchad wrote:
> registration where they ask for what is your favorite sports and there is a
> list of checkboxes and at the bottom there is a check box that says all and
> some how you see the checkbox has a check mark in all the boxes. How is this
> set up within PHP or I guess it will be HTML form tag.

It's not done with PHP, but JavaScript. Do a Google search. You'll find
plenty of scripts.

> What I do not
> understand is what is the structure that if you have more than one checkbox
> which can be different interests, how does that get applied to the database of
> MySQL, is it a VARCHAR, or INT or even LONGTEXT?

Use a SET as the MySQL column type:

http://dev.mysql.com/doc/refman/5.0/en/set.html

All checkboxes should have the same name followed by an empty pair of
square brackets so that they form an array. For example:

<input type="checkbox" name="interests[]" value="tennis" />

If no checkbox is selected, $_POST['interests'] will not exist, so you
need to test for its existence, and then use implode() to turn it into a
string before passing it to the SQL query.

if (isset($_POST['interests'])) {
$interests = implode(',', $_POST['interests']);
}
else {
$interests = '';
}

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines