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

The Archive Base Latest Questions

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

I’m trying to implement a submission system where people can fill out personal information

  • 0

I’m trying to implement a submission system where people can fill out personal information and attach a file upload. Their information should be recorded into a MySQL database and the file should be renamed to one of the fields and then the extension. Here is what I have so far..

This is the form page:

<html>
<head>
<title>Submissions Script DEV</title>
<style type="text/css">
/**** Start page styles ****/

body {
    background: #DFA01B;
    font-family: arial, sans-serif;
    font-size: 14px;
    }

#wrap {
    max-width: 600px;
    margin: 30px auto;
    background: #fff;
    border: 4px solid #FFD16F;
    -moz-border-radius: 15px;
    -webkit-border-radius: 15px;
    border-radius: 15px;
    padding: 20px;
    }
</style>
<body> 
<div id="wrap">
    <div align="center">
    <a href="http://siteurl.com"><img src="logo.png" /> </a>
    <h1 style="font-family:arial">Submissions</h1>
    <p style="font-family:helvetica"> <i> Welcome to the submission page</i> </p> 
</div>
<form method="POST" action="upload.php" enctype="multipart/form-data">
    <p>
              Please enter your first name: <input type="text" name = "fname">
            <p>
              Please enter your last name: <input type="text" name= "lname">
            <p>
              Student #: <input type="text" name= "snumber"/>
            <p>
            Grade: <select name= "grade">
            <option>9</option>
            <option>10</option>
            <option>11</option>
            <option>12</option>
        </select>
        <p>
<hr>
            <!---Upload file section begins--->
              Please attach your Powerpoint (ppt/pptx/zip) file. The file should be     named student#.zip. (For example; 123456.ppt)
        </p>
        <input type="hidden" name="size" value="1024000">
            <input type="file" name="upload"> 

        <p>
        <br/>
        <br/>
        <div align="center">
        <input type=button onClick="location.href='instructions.html'" value='Back'>
        <input TYPE="submit" name="upload" title="Send your submission" value="Submit Portfolio"/>
        </div>
      </form>
<p>   
<!---Footer Styling--->
<div style="font-family: Arial;
font-size: 10px;
color: grey;
align: center;">
<!---Footer Contents--->
    <p>Copyright <a href="http://sitename.com">site</a>site</p>
</div>  
</div>
</body>
</html>

This is the upload.php:

<?php

//This is the directory where images will be saved
$target = "uploads/";
$target = $target . basename( $_FILES['upload']['name']);

//This gets all the other information from the form
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$upload=($_FILES['upload']['name']);
$snumber=$_POST['snumber'];
$grade=$_POST['grade'];

// Connects to your Database
mysql_connect("localhost", "db_user", "dbuserpass") or die(mysql_error()) ;
mysql_select_db("sub-data") or die(mysql_error()) ;

//Writes the information to the database
mysql_query("INSERT INTO `Submissions` VALUES ('$fname', '$lname', '$snumber', '$grade',         '$upload')") ;

//Writes the upload to the server
if(move_uploaded_file($_FILES['upload']['tmp_name'], $target))
{

//Tells you if its all ok
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been recorded";
}
else {

//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
?>

In the end, I hope to use the snumber field from the form to name the file upload. For example, if someone fills out 12345 in the snumber field and uploads a .zip file, it should automatically be renamed to 12345.zip and stored in the appropriate directory.

How would I go about doing this? I’m very new to PHP but I have done some research pertaining to this problem although I haven’t found anything that suits this need.

  • 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-26T02:31:21+00:00Added an answer on May 26, 2026 at 2:31 am

    Just update the $target variable with the value of the destination file name. For example, change

    $target = "uploads/";
    $target = $target . basename( $_FILES['upload']['name']);
    if(move_uploaded_file($_FILES['upload']['tmp_name'], $target))
    

    to

    $extension = explode(".", $_FILES['upload']['name']);
    $extension = $extension[count($extension)-1];
    $target = "uploads/";
    $target = $target . $_POST['snumber'] . "." . $extension;
    if(move_uploaded_file($_FILES['upload']['tmp_name'], $target))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to render a haml file in a javascript response like so:
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters

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.