Op www.ludesign.nl/cancergenomics/nieuw/submit2.php heb ik een inschrijfformulier staan.
- Aan dit documentje zit submit.php (in dezelfde map) gekoppeld die ervoor zorgt dat de gegevens op de juiste manier verstuur worden.
- Echter zit er ook een controle functie in submit2.php echter die schijnt gekoppeld te moeten blijven aan submit2.php wil die zijn functie uitvoeren en de gegevens controleren of deze wel volledig zijn ingevuld.
Weet iemand toevallig een oplossing?
Wat volgens mij het probleem is is dat hij niet EERST dit stukje code uit submit2.php uitvoerd voordat hij hem doorlinkt naar submit.php:
<?
// only validate form when form is submitted
if(isset($submit_button)){
$error_msg='';
if(trim($first_name_input)=='' || strlen(trim($first_name_input)) < 1 || strlen(trim($first_name_input)) > 25) {
$error_msg.="Please fill in your first name(s)<br>";
}
if(trim($surname_input)=='' || strlen(trim($surname_input)) < 1 || strlen(trim($surname_input)) > 25) {
$error_msg.="Please fill in your surname<br>";
}
if(trim($institute_input)=='' || strlen(trim($institute_input)) < 1 || strlen(trim($institute_input)) > 25) {
$error_msg.="Please fill in your affiliation name of institute<br>";
}
if(trim($city_input)=='' || strlen(trim($city_input)) < 1 || strlen(trim($city_input)) > 25) {
$error_msg.="Please fill in your affiliation city<br>";
}
if(trim($phone_input)=='' || strlen(trim($phone_input)) < 7) {
$error_msg.="Please fill in your phone number<br>";
}
if(trim($email_input)=='') {
$error_msg.="Please enter an email<br>";
} else {
// check if email is a valid address in this format username@domain.com
if(!ereg("[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]", $email_input)) $error_msg.="Please enter a valid email address<br>";
}
// display error message if any, if not, proceed to other processing
if($error_msg==''){
// other process here
} else {
echo "<font color=white>$error_msg</font>";
}
}
?>
- Aan dit documentje zit submit.php (in dezelfde map) gekoppeld die ervoor zorgt dat de gegevens op de juiste manier verstuur worden.
- Echter zit er ook een controle functie in submit2.php echter die schijnt gekoppeld te moeten blijven aan submit2.php wil die zijn functie uitvoeren en de gegevens controleren of deze wel volledig zijn ingevuld.
Weet iemand toevallig een oplossing?
Wat volgens mij het probleem is is dat hij niet EERST dit stukje code uit submit2.php uitvoerd voordat hij hem doorlinkt naar submit.php:
<?
// only validate form when form is submitted
if(isset($submit_button)){
$error_msg='';
if(trim($first_name_input)=='' || strlen(trim($first_name_input)) < 1 || strlen(trim($first_name_input)) > 25) {
$error_msg.="Please fill in your first name(s)<br>";
}
if(trim($surname_input)=='' || strlen(trim($surname_input)) < 1 || strlen(trim($surname_input)) > 25) {
$error_msg.="Please fill in your surname<br>";
}
if(trim($institute_input)=='' || strlen(trim($institute_input)) < 1 || strlen(trim($institute_input)) > 25) {
$error_msg.="Please fill in your affiliation name of institute<br>";
}
if(trim($city_input)=='' || strlen(trim($city_input)) < 1 || strlen(trim($city_input)) > 25) {
$error_msg.="Please fill in your affiliation city<br>";
}
if(trim($phone_input)=='' || strlen(trim($phone_input)) < 7) {
$error_msg.="Please fill in your phone number<br>";
}
if(trim($email_input)=='') {
$error_msg.="Please enter an email<br>";
} else {
// check if email is a valid address in this format username@domain.com
if(!ereg("[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]", $email_input)) $error_msg.="Please enter a valid email address<br>";
}
// display error message if any, if not, proceed to other processing
if($error_msg==''){
// other process here
} else {
echo "<font color=white>$error_msg</font>";
}
}
?>
[ Voor 187% gewijzigd door Verwijderd op 10-08-2005 14:13 . Reden: code toegevoegd ]