Support Forum Softcomplex logo
About Us  | Services  | Download  | Order  | Support  | |
| Search | Today's Posts | Stats | Board Rules | Not logged in [ Login | Register ]
go to bottom
Last active: Never

Printable Version | Subscribe | Add to Favourites   Post new thread
Author: Subject: using TFV with a PHP script
Junior Member

Posts: 3
Registered: 1/15/2007
Member Is Offline
posted on 1/15/2007 at 09:43 AM Reply With Quote
using TFV with a PHP script

hey all;

first off great product! i've got the validator finally working correctly and was excited about that. that is until i realized that it has somehow disabled or isnt working with the PHP script i also require.

here's the scenario...

- i've got a form that is required to be filled out to download our company's catalog.
- the TFV is used to validate the fields and make sure required fields are filled out
- when the form is correctly filled out and submitted it SHOULD load the next html page. which it does correctly BUT
- it should also put the info from the form into an .xls file using a PHP script...

now before i started working with TFV, the PHP script was working just great and was collecting the data and dumping it into an .xls file on our server. now after implementing the TFV, it no longer adds the data to the .xls file.

please help.

here is the php code, which resides in a file called catalogForm.php in the same directory as the validator.js file and the .html file that contains the form.
apgForm 1.7
By: Alvaro Prieto (apg88)
E-Mail: [email protected]
Web site:

Licensed under the Creative Commons Attribution 2.5 License - (Summary)
You can modify the code all you want, make money with it, release newer versions, etc... just leave my name, email, and web site URL on the it.


// Change this to the page you want the user to be redirected to after form is submitted (i.e. success.html and error.html)
$success = "catalog_download.html";
$error = "";

// Change this to the character(s) you want to be placed instead of line breaks(new line, enter, etc)
$lbChar = " "; // default is a space, you may change it to whatever you want

// Don't change anything below this line

// Determine if the form was sent through the GET methog or the POST method.
$array = $_POST;
} else if($_GET){
$array = $_GET;
} else {
die("You must Access this file through a form."); // If someone accesses the file directly, it wont work :)

//Check if the filename was sent through the form or not
// if the filename wasnt sent through the form, it will become form.xls, you can change the default if you want.
$array['filename'] = "catDL.xls"; //Set the file to save the information in

} else {
$array['filename'] = $array['filename'] . ".xls";

// Define the tab and carriage return characters:
$tab = "t"; //chr(9);
$cr = "n"; //chr(13);

// Make The Top row for the excel file and store it in the $header variable
$keys = array_keys($array);
foreach($keys as $key){
if(strtolower($key) != 'filename' && strtolower($key) != 'title'){
$header .= $key . $tab;
$header .= $cr;

//Make the line with the contents to write to the excel file.
foreach($keys as $key){
if(strtolower($key) != 'filename' && strtolower($key) != 'title'){

$array[$key] = str_replace("n",$lbChar,$array[$key]);
$array[$key] = preg_replace('/([rn])/e',"ord('$1')==10?'':''",$array[$key]);
$array[$key] = str_replace("\","",$array[$key]);
$array[$key] = str_replace($tab, " ", $array[$key]);
$data .= $array[$key] . $tab ;
$data .= $cr;

if (file_exists($array['filename'])) {
$final_data = $data; // If the file does exist, then only write the information the user sent
} else {
$final_data = $header . $data; // If file does not exist, write the header(first line in excel with titles) to the file
// open the file and write to it

$fp = fopen($array['filename'],"a"); // $fp is now the file pointer to file $array['filename']


fwrite($fp,$final_data); //Write information to the file
fclose($fp); // Close the file
// Success
header("Location: $success");
} else {
// Error
header("Location: $error");


any help on getting this to work is appreciated... and not that i have to mention it, but i'm in dire need of getting this working, so any quick help is appreciated as well.

thanks again for everything... look forward to a response.
View User's Profile View All Posts By User U2U Member
Junior Member

Posts: 3
Registered: 1/15/2007
Member Is Offline
posted on 1/15/2007 at 10:54 AM Reply With Quote

woo hoo!

nevermind, got it working now... simple really, i just wasn't thinking...

all i had to do was change the form action.

it originally was
<form action="catalog_download.html" method="get" name="catalog" onsubmit="return tfv.exec()">

simply had to switch it to
<form action="catalogForm.php" method="get" name="catalog" onsubmit="return tfv.exec()">
View User's Profile View All Posts By User U2U Member
Post new thread

Related Links:
Product Page Product Page
Product Demonstrations Product Demos
Registration Form Validation
Login Form Validation
Free Download Free Download
Product Documentation Documentation
Documenation Page
Change Log
Validators Comparison Table
Support Forum Support Forum

Go To Top

Powered by XMB 1.9.1 Nexus
Developed By Aventure Media & The XMB Group © 2002-2004