[m]
05-09-2003, 06:22 AM
ok I have this script that I'm working on where I get input of an email the script validates it and is supposed to check weather or not the information is already present if it is not then the script writes down the new address. the problem is that I can't get it to check if the address is already there
can you fix it for me?
I have found out that the problem has something to do with the IF statement:
if ($list == $email){
maby it is that the $list is made from an array or something?
I can't seem to figure it out but I'm learning...I have searched through one of my books but found nothing to help me with this problem
<?php
if (eregi(".+@.+\..+", $email)) {
$TheFile = "data.php";
$Data = file($TheFile);
$n = 0;
while ($n < count($Data)){
$list = $Data[$n];
if ($list == $email){
print "$list <BR>\n";
print "";
$absent = FALSE;
print "The address $email already exists on the list<br>\n";
}
$n++;
}
if ($absent) {
$open = fopen($TheFile, "a+");
if ($open) {
fwrite ($open, "$email\n");
fclose($open);
print "your address: $email has been recived<br>\n";
} else {
print "there was an error in the process<br>\n";
}
}
} else {
print "$email is not a valid e-mail address\n";
}
?>f
can you fix it for me?
I have found out that the problem has something to do with the IF statement:
if ($list == $email){
maby it is that the $list is made from an array or something?
I can't seem to figure it out but I'm learning...I have searched through one of my books but found nothing to help me with this problem
<?php
if (eregi(".+@.+\..+", $email)) {
$TheFile = "data.php";
$Data = file($TheFile);
$n = 0;
while ($n < count($Data)){
$list = $Data[$n];
if ($list == $email){
print "$list <BR>\n";
print "";
$absent = FALSE;
print "The address $email already exists on the list<br>\n";
}
$n++;
}
if ($absent) {
$open = fopen($TheFile, "a+");
if ($open) {
fwrite ($open, "$email\n");
fclose($open);
print "your address: $email has been recived<br>\n";
} else {
print "there was an error in the process<br>\n";
}
}
} else {
print "$email is not a valid e-mail address\n";
}
?>f