Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8605255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:47:00+00:00 2026-06-12T02:47:00+00:00

how can i customize the text name for the output on my fopen? i

  • 0

how can i customize the text name for the output on my fopen?
i tried using

$file = $Aname .'.txt';

but it won’t output correctly, and also after creating the text file return to the page
and prompt the user regarding the creation of the file .

<?php
$saving = $_REQUEST['saving'];
if ($saving == 1){ 
$Aname = $_POST['Aname'];

$name = $_POST['name']; 
$last = $_POST['last']; 
$mob = $_POST['mob']; 
$ext = $_POST['ext']; 
$email = $_POST['email']; 
$add = $_POST['add']; 
$com = $_POST['com']; 
$day = $_POST['day']; 
$text = $_POST['text'];
$date = date("M j, Y "); 

$data = "Date Sent: {$date}\n\nName: {$name} {$last}\nPhone : {$mob} ext: {$ext}\nCompany: {$com}\nAddress : {$add}\nE-mail : {$email}\nDay : {$day}\n\nNote :

\n{$text}\n---------------------------------------\n";

$file = $Aname.'.txt';

$fp = fopen($file, "a") or die("Couldn't open $file for writing!");
fwrite($fp, $data) or die("Couldn't write values to file!"); 

fclose($fp); 
}
?>

and also instead of relocating the user to another page to give this error

die("Couldn't write values to file!"); 

just pop up an alert on the page.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:47:01+00:00Added an answer on June 12, 2026 at 2:47 am

    Try using file_put_contents(). It replaces the whole fopen, fwrite, fclose headache.
    http://php.net/manual/en/function.file-put-contents.php

    <?php
    $saving = $_REQUEST['saving'];
    if ($saving == 1){ 
    $Aname = $_POST['Aname'];
    
    $name = $_POST['name']; 
    $last = $_POST['last']; 
    $mob = $_POST['mob']; 
    $ext = $_POST['ext']; 
    $email = $_POST['email']; 
    $add = $_POST['add']; 
    $com = $_POST['com']; 
    $day = $_POST['day']; 
    $text = $_POST['text'];
    $date = date("M j, Y "); 
    
    $data = "Date Sent: {$date}\n\nName: {$name} {$last}\nPhone : {$mob} ext: {$ext}\nCompany: {$com}\nAddress : {$add}\nE-mail : {$email}\nDay : {$day}\n\nNote :
    
    \n{$text}\n---------------------------------------\n";
    
    $file = $Aname.'.txt';
    
    file_put_contents ( $file, $data ); 
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that you can change text editor colours but all the things I
I am creating a customized listview header that has the header text but also
How can I customize the text that is rendered with the LabelFor() method? I
I found out about GWT's CustomScrollPanel and how you can customize the scroll bar,
I want to have a flexible templating language that I can customize for a
In Firefox, we can customize the default values for HTTP headers, let's say for
When registering a product, the user can customize the URL of it! As the
How can I customize the error messages for sub options when validating numericality on
please provide me the possibility of my issue. Can we customize the push notification
How to customize KNPMenuBundle? I can't figure out how to add an image or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.