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 4055762
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:44:31+00:00 2026-05-20T14:44:31+00:00

I have a form with an entry textbox that is identified as username .

  • 0

I have a form with an entry textbox that is identified as username.
When the submit button is pressed this code is used:

<?php
if (isset($_POST['submit'])) {
$myUser=$_POST['username'];  
$path="/data/www/vhosts/themacsplash.com/httpdocs/ClipBoy/userfiles/";
$fpath="/data/www/vhosts/themacsplash.com/httpdocs/ClipBoy/userfiles/user.php";
$myFolder = $path . $myUser;
$myFile = $myUser.".php";
$old_umask = umask(0);
mkdir($myFolder, 0777);
$myFileDes = $myFolder."/".$myFile;
copy($fpath, $myFileDes);  
umask($old_mask);
}
?>

This creates a directory and a file, the file is duplicated from user.php In user.php there is this code that needs to be changed upon submit:

$result = mysql_query("SELECT link, notes FROM links WHERE username='will';");

It needs to change where it says username='will';
It needs to change will to the username defined in the form.

How would I do this?

  • 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-20T14:44:32+00:00Added an answer on May 20, 2026 at 2:44 pm

    You can get the username dynamically from the directory the file is inside. Use dirname and __FILE__ to get:

    $username = dirname(__FILE__);
    $username = mysql_real_escape_string($username);
    $result = mysql_query("SELECT link, notes FROM links WHERE username='" . $username . "';");
    

    Also i would advise you to filter the input from the user:

    $myUser = preg_replace('/[^a-zA-Z0-9_]/', '', $myUser);
    

    This would replace every character that is no alphanumerical character or an underscore by an empty string. Otherwise the user can select "../../../foo/" as username which would probably break the script.

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

Sidebar

Related Questions

I have a very simple entry form. After a button is pressed, I need
I have a form that is used for data entry, and on one form
I have a asp:textbox taking a Username that is part of a Signup form
We have an entry form that gives the user a calendar drop down, but
I have a button that will create a new entry (row in a table)
I have a data entry form with many textbox's and some dropdowns for the
I do have an html form that accepts textbox input of sha1 hashes per
I have a WinForms data entry form that will have upwards of 1500 questions.
I have a WPF MVVM app that contains a data entry form with several
There is a textbox and a button that validates the entry inside the textbox.

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.