initial fixes for participant registration

This commit is contained in:
arman 2025-02-02 05:42:23 +00:00
parent 4b6e9abefe
commit c4981740fa
4 changed files with 19 additions and 15 deletions

View File

@ -903,7 +903,7 @@ LOCK TABLES `emailqueue_recipients` WRITE;
UNLOCK TABLES; UNLOCK TABLES;
-- --
-- Table structure for table `emails` -- Table structure for table `git
-- --
DROP TABLE IF EXISTS `emails`; DROP TABLE IF EXISTS `emails`;
@ -3223,7 +3223,7 @@ CREATE TABLE `students` (
`lang` char(2) NOT NULL DEFAULT '', `lang` char(2) NOT NULL DEFAULT '',
`year` int(11) NOT NULL DEFAULT 0, `year` int(11) NOT NULL DEFAULT 0,
`schools_id` int(10) unsigned NOT NULL DEFAULT 0, `schools_id` int(10) unsigned NOT NULL DEFAULT 0,
`fairs_id` int(11) NOT NULL, `fairs_id` int(11) NOT NULL DEFAULT 0,
`tshirt` varchar(32) NOT NULL DEFAULT 'medium', `tshirt` varchar(32) NOT NULL DEFAULT 'medium',
`medicalalert` varchar(255) NOT NULL DEFAULT '', `medicalalert` varchar(255) NOT NULL DEFAULT '',
`foodreq` varchar(255) NOT NULL DEFAULT '', `foodreq` varchar(255) NOT NULL DEFAULT '',

View File

@ -153,7 +153,7 @@ if (get_value_from_array($_POST, 'save') == 'edit' || get_value_from_array($_POS
$sh['username'] = $em; $sh['username'] = $em;
user_save($sh); user_save($sh);
} }
$exec = 'UPDATE schools SET ' $exec = 'UPDATE schools SET '
. "school='" . get_value_from_array($_POST, 'school') . "', " . "school='" . get_value_from_array($_POST, 'school') . "', "
. "schoollang='" . get_value_from_array($_POST, 'schoollang') . "', " . "schoollang='" . get_value_from_array($_POST, 'schoollang') . "', "
@ -170,8 +170,8 @@ if (get_value_from_array($_POST, 'save') == 'edit' || get_value_from_array($_POS
. "phone='" . get_value_from_array($_POST, 'phone') . "', " . "phone='" . get_value_from_array($_POST, 'phone') . "', "
. "fax='" . get_value_from_array($_POST, 'fax') . "', " . "fax='" . get_value_from_array($_POST, 'fax') . "', "
. "registration_password='" . get_value_from_array($_POST, 'registration_password') . "', " . "registration_password='" . get_value_from_array($_POST, 'registration_password') . "', "
. "projectlimit='" . get_value_from_array($_POST, 'projectlimit') . "', " . "projectlimit='" . get_value_from_array($_POST, 'projectlimit', 0) . "', "
. "projectlimitper='" . get_value_from_array($_POST, 'projectlimitper') . "', " . "projectlimitper='" . get_value_from_array($_POST, 'projectlimitper', 'total') . "', "
. "accesscode='" . get_value_from_array($_POST, 'accesscode') . "', " . "accesscode='" . get_value_from_array($_POST, 'accesscode') . "', "
. $sciencehead_update . $principal_update . $sciencehead_update . $principal_update
. "atrisk='$atrisk' " . "atrisk='$atrisk' "

View File

@ -712,10 +712,21 @@ function emit_month_selector($name, $selected = '')
$s = ''; $s = '';
echo "<option $s value=\"$x\">" . $months[$x] . "</option>\n"; echo "<option $s value=\"$x\">" . $months[$x] . "</option>\n";
} }
// returns true if its a valid email address, false if its not
echo "</select>\n"; echo "</select>\n";
} }
function isEmailAddress($str)
{
if (preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/i", $str))
return true;
else
return false;
}
function emit_day_selector($name, $selected = '') function emit_day_selector($name, $selected = '')
{ {
echo "<select name=\"$name\">\n"; echo "<select name=\"$name\">\n";
@ -864,14 +875,6 @@ function outputStatus($status)
return $ret; return $ret;
} }
// returns true if its a valid email address, false if its not
function isEmailAddress($str)
{
if (preg_match('/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})$/i', $str))
return true;
else
return false;
}
function communication_get_user_replacements(&$u) function communication_get_user_replacements(&$u)
{ {

View File

@ -39,6 +39,7 @@ if (get_value_from_array($_POST, 'action') == 'new') {
$r = $q->fetch(PDO::FETCH_OBJ); $r = $q->fetch(PDO::FETCH_OBJ);
$_SESSION['registration_number'] = $r->num; $_SESSION['registration_number'] = $r->num;
$_SESSION['registration_id'] = $r->id; $_SESSION['registration_id'] = $r->id;
$r->schools_id = $r->schools_id ?? 0;
$stmt = $pdo->prepare("INSERT INTO students (registrations_id,email,schools_id,year) VALUES ('$r->id','" . $_SESSION['email'] . "','" . $r->schools_id . "','" . $config['FAIRYEAR'] . "')"); $stmt = $pdo->prepare("INSERT INTO students (registrations_id,email,schools_id,year) VALUES ('$r->id','" . $_SESSION['email'] . "','" . $r->schools_id . "','" . $config['FAIRYEAR'] . "')");
$stmt->execute(); $stmt->execute();
@ -125,7 +126,7 @@ send_header('Participant Registration');
if (get_value_from_array($_POST, 'action') == 'login' && (get_value_from_array($_POST, 'email') || get_value_from_array($_SESSION, 'email'))) { if (get_value_from_array($_POST, 'action') == 'login' && (get_value_from_array($_POST, 'email') || get_value_from_array($_SESSION, 'email'))) {
if (get_value_from_array($_POST, 'email')) if (get_value_from_array($_POST, 'email'))
$_SESSION['email'] = stripslashes($pdo->quote($_POST['email'])); $_SESSION['email'] = stripslashes($_POST['email']);
echo '<form method="post" action="register_participants.php">'; echo '<form method="post" action="register_participants.php">';