SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Jun 2007
    Plymouth uk
    0 Post(s)
    0 Thread(s)

    Need a little more help Please

    basic is peeps join fill out form and details go to database with a temp pname
    then they can upload a photo to uploads after they have renamed it to there mysql id which is shown when they login so where would i put the code to update pname

    here is the code i have so far

    PHP Code:
    //Retrieves data from MySQL

    $data mysql_query("SELECT * FROM test where email='$myemail'") or die(mysql_error());
    $count mysql_num_rows($data);
     if (
    $count==0) { 
    header ("Location: wrong.html");
    } else {

    //Puts it into an array 
    while($info mysql_fetch_array$data )) 

    //Outputs the image and other data

    Echo "<p class=\"style1\"><b>This is your ID rename your photo to </b> ".$info['ID'] . ".jpg </p>";

    <h3 align="center">Upload Photo</h3>
                <p align="center">use this form to upload your photo as a jpg </p>
                 <p align="center">if you have no photo click no photo</p>
              <form action="formtoemailpro2.php" method="post" enctype="multipart/form-data">
                <table border="0" align="center" cellspacing="5" bgcolor="#ececec">
    <tr><td>Your Name:</td><td><input type="text" size="30" name="name"></td></tr>
    <tr><td> Photo:</td><td><input type="file" name="pic"></td></tr> 
    </td><td><input type="submit" value="Send"></td></tr>
    </td><td><input type="button" value="No Photo:" onclick="window.location.href='index.html'" /></td></tr>

    and this is what it looks like on screen

    Attached Images Attached Images
    an old man of 60 trying to keep up with the youngsters he he

  2. #2
    SitePoint Addict
    Join Date
    Jul 2008
    0 Post(s)
    0 Thread(s)
    It is probably just as easy and more reliable to rename the file yourself via your script. You have your form submitting to formtoemailpro2.php. This is where you would handle the upload and renaming. My thought would be to include a hidden field with the id in the upload and name form you have above. Then use move_uploaded_file to move the file to your preferred directory as well as rename it. Also see Handling file uploads

  3. #3
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Lancaster University, UK
    2 Post(s)
    0 Thread(s)
    Why make the user input their ID?

    The form processor should already be aware of that ID (via a session) so it should be renamed by your code, not by the user.

    Also, what happens when the user wants to upload multiple photos? If that could be the case, you should really reconsider your database structure.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts