Hola a todos!
Tengo un problema con este script

es que miren y me ayudan
Código PHP:
Ver original<?php
include('conexion.php');
include('autor.php');
$accdir="D:\\cuentas\\primero\\2010";
$title = 'Sistema 1';
if ($_POST['action'] == 'submitted')
{
$Email = $_POST['txtEmail'];
$UserID = $_POST['userid'];
$Password = $_POST['password'];
$CPassword = $_POST['password2'];
$UserKey = $_POST['txtKey'];
$SecretQuestion = $_POST['txtQuest'];
$Answer = $_POST['txtAnswer'];
$FirstName = $_POST['txtName'];
$LastName = $_POST['txtLastName'];
$Month = $_POST['txtMonth'];
$Day = $_POST['txtDay'];
$Year = $_POST['txtYear'];
$Sex = $_POST['txtSex'];
$Country = $_POST['txtCountry'];
function is_email($email){
$x = '\d\w!\#\$%&\'*+\-/=?\^_`{|}~';
&& preg_match("#^[$x]+(\.?([$x]+\.)*[$x]+)?$#", $email[0]) && preg_match('#^(([a-z0-9]+-*)?[a-z0-9]+\.)+[a-z]{2,6}.?$#', $email[1]); }
$error = "";
function AllOK()
{
global $error,$Email,$UserID,$Password,$CPassword,$UserKey,$SecretQuestion,$Answer,$FirstName,$MI,$LastName,$Month,$Day,$Year,$Sex,$Address,$Country;
$error .= "'$UserID', Nombre de usuario no valido. Solo letras, se permiten números en este campo (longitud 6 ~ 50).<br/>";
return 0;
}
$error .= "Contraseña no valida. Solo letras, se permiten números en este campo (longitud 6 ~ 30).<br/>";
return 0;
}
$error .= "Llave secreta no valida. Debe ser un numero de 7 digitos.<br/>";
return 0;
}
if ($Password != $CPassword) {
$error .= "Las contraseñas no coinciden...<br/>";
return 0;
}
$SecretQuestion = str_replace("'", "''", $SecretQuestion);
if (!is_email($Email)) {
$error .= "Correo electronico no valido.<br/>";
return 0;
}
$error .= "Respuesta no valida.. Solo letras y numeros estan permitidos.<br/>";
return 0;
}
$error .= "Nombre no valido.. Solo letras estan permitidas.<br/>";
return 0;
}
$error .= "Apellido no valido.. Solo letras estan permitidas.<br/>";
return 0;
}
$error .= "Inicial no valido. Solo letras estan permitidas.<br/>";
return 0;
}
if ($Month > 12 || $Month < 1 || !preg_match("/^[0-9]/", $Month) || strlen($Month) == "0") { $error .= "Mes de fecha de nacimiento no valido.<br/>";
return 0;
}
if ($Day > 31 || $Day < 1 || !preg_match("/^[0-9]/", $Day) || strlen($Day) == "0") { $error .= "Dia de fecha de nacimiento no valido.<br/>";
return 0;
}
if ($Year > 2007 || $Year < 1950 || !preg_match("/^[0-9]/", $Year) || strlen($Year) == "0") { $error .= "Año de fecha de nacimiento no valido.<br/>";
return 0;
}
if ($Sex != 1 && $Sex != 2) {
$error .= "Genero no valido.<br/>";
return 0;
}
if (!preg_match("/^[a-zA-Z 0-9_-]+$/", $Country)) { $error .= "País no valido.<br/>";
return 0;
}
if(file_exists($accdir."\\".$initial."\\".$userid.".tad")) {
$error .= "Account already exist.";
return 0;
}
$wea = mssql_query("SELECT UserID FROM Account where UserID='$UserID'");
if ($row[0] != "") {
$error .= "Nombre de usuario en uso, Porfavor elije otro.<br/>";
return 0;
}
$wea2 = mssql_query("SELECT Email FROM Account where Email='$Email'");
if ($row2[0] != "") {
$error .= "Email en uso, Porfavor selecciona otro.<br/>";
return 0;
}
return 1;
}
if (!AllOK())
{
$result = $error;
}
else //BUENO EN ESTA PARTE QUIERO METER EL USER Y EL PASS EN UN ARCHIVO .TD QUE ES BINARIO
{
$result = "¡Cuenta registrada con exito!";
$initial="etc";
$f=@fopen("./inc/sample.tad",r
) or
die("Error"); // esta parte esta fatal $demoid=substr($acc,0,$userlenght); $f2=@fopen($accdir."\\".$initial."\\".$userid.".tad",a
);
mssql_query("INSERT INTO Account VALUES ('$Email', '$UserID', '$Password' , '$UserKey', '0', NULL, NULL, NULL, '$SecretQuestion', '$Answer', '$FirstName', '$MI', '$LastName', '$Month/$Day/$Year 00:00:00', '$Sex', '$Address', NULL, NULL, '$Country', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '$_SERVER[REMOTE_ADDR]', newid(), GETDATE(), 1, NULL, 0, 0, 0, NULL, 0, 1, NULL, 0, 0, NULL, NULL, 0)"); @NCashResult int,
@NCashMsg nvarchar(100)
EXEC @return_value = [dbo].[AccountInsertUserInBilling]
@Email = N'".$Email."',
@NCashResult = @NCashResult OUTPUT,
@NCashMsg = @NCashMsg OUTPUT");
}
include('plantilla/registrocompleto.php');
}
else
{
include('plantilla/registro.php');
}
?>
Pues el asunto es que aparte de que haga la modificación y lo genere también guarde los datos en mi tabla pues el ya hace el INSERT pero lo del archivo nop

ayúdenme plix no soy muy experta en esto.... (Perdonen si el código es un desastre).