VictorProfundus
12-15-2007, 01:47 AM
I am working with a form and submitting it through a php file.
When the form is submitted the php sends an email to the submitted email address, and to the administrator's email address. It also writes the message to a text file.
As of now, I have this set up so that it writes each submission to the same file....however, I would like to be able to have the php write the submission to a different file each time...based off of their inputted username for instance.
Here is the code I have:
$date=date("D F d Y");
$time=time();
$username=$_POST['username'];
$email=$_POST['email'];
$job=$_POST['job'];
$posts=$_POST['posts'];
$why=$_POST['why'];
$approved=$_POST['approved'];
$ip=$_SERVER['REMOTE_ADDR'];
$victor="**REMOVED**";
$file="staffapp.txt";
$jofnn="**REMOVED**";
$inputString = "$time, $date\n\n$username has applied for a staff position.\n\nHere is the information sumitted:\n\nUSERNAME: $username\n\nEMAIL: $email\n\nAPPLYING FOR: $job\n\nNUMBER OF POSTS: $posts\n\nINFO: $why\n\n$approved\n\nIP ADDRESS: $ip\n\n====================================\n\n";
$fp = fopen( $file , "a" );
fwrite( $fp, $inputString );
fclose( $fp );
$to="$victor";
$message2="$username,\nThank you for submitting your application!\nThe Administrators of the board shall review your application and get back to you in due course.\n\nThe following is your submitted information:\nUSERNAME: $username\nEMAIL: $email\nAPPLYING FOR: $job\nNUMBER OF POSTS: $posts\nINFO: $why\n**\n$approved\n**\nThanks again,\n The Global Forums Team\n\n------------\nThis is an automated message, please don't reply!";
$message="Global Forums Administrators,\nThe following is a pending staff application.\n---------------\n\nUSERNAME: $username\n\nEMAIL: $email\n\nAPPLYING FOR: $job\n\nNUMBER OF POSTS: $posts\n\nINFO: $why\n\n$approved\n\nIP ADDRESS: $ip\n\nSubmission Logged: **URL REMOVED**\n===============================\nCopy of Submitted email:\n----\n$message2";
mail($to,"GF Staff Application",$message,"From: $email");
mail($email,"GF Staff Application Submission",$message2,"From: $to");
header( "Location: **URL REMOVED**");
Is there anyway to create a new text file for each submission and name it according to their username?
When the form is submitted the php sends an email to the submitted email address, and to the administrator's email address. It also writes the message to a text file.
As of now, I have this set up so that it writes each submission to the same file....however, I would like to be able to have the php write the submission to a different file each time...based off of their inputted username for instance.
Here is the code I have:
$date=date("D F d Y");
$time=time();
$username=$_POST['username'];
$email=$_POST['email'];
$job=$_POST['job'];
$posts=$_POST['posts'];
$why=$_POST['why'];
$approved=$_POST['approved'];
$ip=$_SERVER['REMOTE_ADDR'];
$victor="**REMOVED**";
$file="staffapp.txt";
$jofnn="**REMOVED**";
$inputString = "$time, $date\n\n$username has applied for a staff position.\n\nHere is the information sumitted:\n\nUSERNAME: $username\n\nEMAIL: $email\n\nAPPLYING FOR: $job\n\nNUMBER OF POSTS: $posts\n\nINFO: $why\n\n$approved\n\nIP ADDRESS: $ip\n\n====================================\n\n";
$fp = fopen( $file , "a" );
fwrite( $fp, $inputString );
fclose( $fp );
$to="$victor";
$message2="$username,\nThank you for submitting your application!\nThe Administrators of the board shall review your application and get back to you in due course.\n\nThe following is your submitted information:\nUSERNAME: $username\nEMAIL: $email\nAPPLYING FOR: $job\nNUMBER OF POSTS: $posts\nINFO: $why\n**\n$approved\n**\nThanks again,\n The Global Forums Team\n\n------------\nThis is an automated message, please don't reply!";
$message="Global Forums Administrators,\nThe following is a pending staff application.\n---------------\n\nUSERNAME: $username\n\nEMAIL: $email\n\nAPPLYING FOR: $job\n\nNUMBER OF POSTS: $posts\n\nINFO: $why\n\n$approved\n\nIP ADDRESS: $ip\n\nSubmission Logged: **URL REMOVED**\n===============================\nCopy of Submitted email:\n----\n$message2";
mail($to,"GF Staff Application",$message,"From: $email");
mail($email,"GF Staff Application Submission",$message2,"From: $to");
header( "Location: **URL REMOVED**");
Is there anyway to create a new text file for each submission and name it according to their username?