I've completed most of this, but am having issues with the following:
1. Form validation. The preg_match is giving me a headache. I'd like to get my form fields to stop all characters that aren't needed, but as of now I can only get simple simple things to work. Here is my code for the errors (verify function). If somebody could suggest some good preg match regexp strings, I'd love you. I've tried everything, I'm just going crazy. haha!
<?php
function VerifyForm(&$values, &$errors)
{
include("connect.php"); // Connects to DB
// Do all necessary form verification
// escape all
foreach($values as $key=>$value){
$values[$key] = mysql_real_escape_string($value);
}
$ParticipantName=$values['ParticipantName'];
if($ParticipantName == ''){
$errors['ParticipantName'] = 'Must be 5 to 30 Characters, and contain only letters and dashes.';
}
$ParticipantBday=$values['ParticipantBday'];
if($ParticipantBday == ''){
$errors['ParticipantBday'] = 'Not a Valid Date.';
}
$ParentName=$values['ParentName'];
if($ParentName == ''){
$errors['ParentName'] = 'Must be 5 to 30 Characters, and contain only letters and dashes.';
}
$Email=$values['Email'];
if(
($Email == '') ||
(strpos($Email, "@") <= 0)
){
$errors['Email'] = 'Invalid Email Address.';
}
$Phone=$values['Phone'];
if($Phone == '') {
$errors['Phone'] = 'Invalid Phone Number.';
}
$Camp=$values['Camp'];
if (!is_numeric($Camp))
$errors['Camp'] = 'Invalid Camp Selection.';
$Terms=$values['Terms'];
if(($Terms == NULL))
$errors['Terms'] = 'You Must Agree to the Terms.';
mysql_close();
return (count($errors) == 0);
}
?>
2. This one is also giving me a headache. I have a "camp_list.php" - which is an admin page. This page takes the input from the link (camp_list.php?campid=X), where X is a number corresponding to the given campID. It uses this to display all registrants for that Camp into a table. I can do this successfully.
I also display the current camp information from the SQL database into form fields, read to be edited. I have an update script that correctly writes the updates to the database. However, my problem arrives because I am submitting a form, and cannot keep my "_GET" variable in the page when I reload (after calling my verify_form function, and trying to display the errors).
In other words, I need to keep the page link the same, OR find a way to submit a POST form, but also place a GET variable in the form somehow, so that the page reloads correctly. Without this, I can't actually reach my "update sql database" function.
I'm not sure this makes sense, but if it does, please help!
THANKS!


Sign In
Create Account


Back to top









