|
13 | 13 | ); |
14 | 14 |
|
15 | 15 | // Add text inputs. (input type, name/id, default data, validation flags, label, helper message, validation warning message). |
16 | | - $form->add('realname', 'text', 'Default text.', array('required'), 'Name', '', 'Your name is required.'); |
17 | | - $form->add('username', 'text', '', array('required', 'lengthmin 2'), 'Screen Name', '', 'Your screen name is required.'); |
18 | | - $form->add('email', 'text', '', array('required', 'email'), 'Email', '', 'Your email is required.'); |
19 | | - $form->add('phone', 'text', '', array('phone'), 'Phone Number', 'We\'ll send you a quick reminder the day before the event!', 'Your phone number must be valid.'); |
| 16 | + $form->add('realname', 'text', 'Default text.', ['required'], 'Name', '', 'Your name is required.'); |
| 17 | + $form->add('username', 'text', '', ['required', 'lengthmin 2'], 'Screen Name', '', 'Your screen name is required.'); |
| 18 | + $form->add('email', 'text', '', ['required', 'email'], 'Email', '', 'Your email is required.'); |
| 19 | + $form->add('phone', 'text', '', ['phone'], 'Phone Number', 'We\'ll send you a quick reminder the day before the event!', 'Your phone number must be valid.'); |
20 | 20 |
|
21 | 21 | // Add text area. |
22 | | - $form->add('suggestions', 'textarea', '', array(''), 'Suggestion Box', 'Have your voice heard!', ''); |
| 22 | + $form->add('suggestions', 'textarea', '', [''], 'Suggestion Box', 'Have your voice heard!', ''); |
23 | 23 |
|
24 | 24 | // Add drop down list. |
25 | | - $form->add('race', 'dropdown', '', array('required'), 'Your Race', '', 'Your selection is required.'); |
| 25 | + $form->add('race', 'dropdown', '', ['required'], 'Your Race', '', 'Your selection is required.'); |
26 | 26 | $form->addDropdownEntry('race', 'Ready to roll out! (Terran)', 'terran'); |
27 | 27 | $form->addDropdownEntry('race', 'My life for Auir! (Protoss)', 'protoss'); |
28 | 28 | $form->addDropdownEntry('race', 'Here\'s for the swarm! (Zerg)', 'zerg'); |
29 | 29 | $form->addDropdownEntry('race', 'Ballin out of control! (Random)', 'random'); |
30 | 30 |
|
31 | 31 | // Add radio button list. |
32 | | - $form->add('beverage', 'radio', '', array('required'), 'Preferred Beverage', '', 'Your selection is required.'); |
| 32 | + $form->add('beverage', 'radio', '', ['required'], 'Preferred Beverage', '', 'Your selection is required.'); |
33 | 33 | $form->addRadioButton('beverage', 'Coffee', 0); |
34 | 34 | $form->addRadioButton('beverage', 'Tea', 1); |
35 | 35 | $form->addRadioButton('beverage', 'Bawls', 2); |
36 | 36 |
|
37 | 37 | // Add check box. |
38 | | - $form->add('notify', 'checkbox', true, array(''), 'Notify me of future gaming events in my area.', '', ''); |
| 38 | + $form->add('notify', 'checkbox', true, [''], 'Notify me of future gaming events in my area.', '', ''); |
39 | 39 |
|
40 | 40 | // Did the form validate successfully? |
41 | 41 | if($form->validate()) |
|
83 | 83 | try |
84 | 84 | { |
85 | 85 | // Connect to Database. |
86 | | - $dbh = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME.";port=".DB_HOST_PORT, DB_USER, DB_PASSWORD, array( PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING )); |
87 | | - $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); |
| 86 | + $dbh = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME.";port=".DB_HOST_PORT, DB_USER, DB_PASSWORD, [PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING ]); |
88 | 87 |
|
89 | 88 | // Is this email already registered? |
90 | 89 | $query = $dbh->prepare("SELECT email FROM attendees WHERE email=:email LIMIT 1"); |
|
135 | 134 | <!DOCTYPE html> |
136 | 135 | <html> |
137 | 136 | <head> |
138 | | - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
139 | 137 | <title>SimplePHPForm Advanced Example</title> |
140 | 138 | <link rel="stylesheet" type="text/css" media="screen" href="css/simplephpform_default.css" /> |
141 | | -</head> |
| 139 | +</head> |
142 | 140 | <body> |
143 | 141 | <?php echo $form->displayState(); ?> |
144 | 142 | <form method="post" action="advanced.php" class="simplephpform"> |
|
0 commit comments