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

  • Home
  • SEARCH
  • 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 4251324
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:38:47+00:00 2026-05-21T04:38:47+00:00

Ok, so I have a form that takes a username and a code. This

  • 0

Ok, so I have a form that takes a username and a code. This is then passed to php for processing. I am not super php saavy, so I want to be able to take a specific portion of the out put and write it to a text file, this form would be used over and over, and I want the text to be appended to the file. As you can see from the output I’m looking to capture, it’s basically writing to some code that will be used for usernames in a css. So here is what I have…

  1. The HTML Form

<html><body>
<h4>Codes Form</h4>
<form action="codes.php" method="post"> 
Username: <input name="Username" type="text" />
Usercode: <input name="Usercode" type="text" /> 
<input type="submit" value="Post It!" />
</form>
</body></html>
  1. The PHP


--><html><body> <?php $Usercode = $_POST['Usercode']; $Username = $_POST['Username'];

echo "You have recorded the following in our system ". $Username . " " . $Usercode . ".<br />"; echo "Thanks for contributing!";

echo .author[href$="/$Username"]:after { echo content: "($Usercode)" echo }

?> </body></html>

All that I would like to be written to the text file would be this portion..


--> .author[href$="/$Username"]:after { content: "($Usercode)" }

Basically, the text file would have line after line of that exact same code, but with different usernames and usercodes. Hopefully, the variable $Usercode and $Username can also be captured and written into the output in the manner that I have it written. I’m just baffled by output buffering in php and clean and flush etc, and fwrite doesn’t seem to be able to write without wiping a file clean each time it writes to it. I may be wrong of course. Anyone care to help?

  • 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-05-21T04:38:48+00:00Added an answer on May 21, 2026 at 4:38 am

    Try this:

    <?php
    $output = "--> .author[href=$Username]:after { \n"
           ."content: ($Usercode)\n"
           ."}";
    $fp = fopen($file, 'a');
    fwrite($fp, $output);
    fwrite($fp, "\n");
    fclose($fp);
    ?>
    

    The flag a will open already a text file and place the pointer to the end of file, so this will not overwrite your already file, more information in fopen.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Windows Form that takes quite a bit of time to load
I have a multipart form that takes basic user information at the beginning with
I have an SQL query that takes the following form: UPDATE foo SET flag=true
I have an HttpHandler on my webserver that takes a URL in the form
Say I want to have a simple web app that takes some user input,
I have this applescript that takes the selected item and zips that file/folder and
I have this code to submit a form automatically on page load, but it
I have this code in the php file. it lists all the interests as
I have a usercontrol that is meant to take up the entire form. I
I have form that displays several keywords (standard set of choice lists that changes

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.