...

View Full Version : form validation to csv



1337hovie
02-08-2010, 04:15 PM
Ok so i need to validate a telephone number field(s)

its like this:
(area)prefix-suffix
(3 diff fields)
i need them to be REQUIRED(3,3,4)
but i really need them to write into the CSV, into one cell.
here;s how im posting now. it gives me an error if i do $area$pre$suf, in replace of $phone..

//this is where the creating of the csv takes place
$cvsData = $fn . "," . $ln . "," . $address . "," . $city . "," . $state . "," . $zip . "," . $phone . "," . $email . "," .$school . "," . $src ."\n";
//write to the file
$fp = fopen("excel.csv","a");
$fp2 = fopen("archive.csv","a"); // $fp is now the file pointer to file $filename
if($fp){
fwrite($fp,$cvsData);
fwrite($fp2,$cvsData);// Write information to the file
fclose($fp);
fclose($fp2); // Close the file
$message = 'Submission successfull. Thank you!';
$aClass = 'normFrmClass';

?>

Fumigator
02-08-2010, 05:50 PM
it gives me an error if i do $area$pre$suf, in replace of $phone..

Care to share? Or should we guess at the error you're getting? Also, when you echo the $area, $pre, and $suf variables, what do you see?

FYI, you might be interested in the fputcsv() function, which does the formatting for you:

http://us3.php.net/manual/en/function.fputcsv.php

1337hovie
02-08-2010, 06:25 PM
it works. just had to make a
$phone = $area$pre$suf

I just need to make a way to VALIDATE this. ive searched EVERYWHERE for a script.
i just need the area field to have a req 3, pre needs a req 3, and suf a req 4.

So that it will show an error, if there isnt 3,3,4 characters in that field.

I need it to be on same page, not POST to a validate script. because its fwriting to a .csv.

recap: need to make the phone number fields ahve a REQUIRED min. character length of 3,3,4. (area)prefix-suffix. (555)555-5555.
thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum