Merging my Image uploader with my Database

Discussion in 'Web Design and Development' started by Cabbit, Jul 14, 2007.

  1. Cabbit macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland
    #1
    Ok i have a working image uploader i would like to add a stamp to the images with the $username, and then send this information to my database user table under the feild avatar.

    Database:

    users: username, avatar.

    Upload code.
    PHP:
    <?php 
    $idir 
    "profile_img/";   // Path To Images Directory 
    $tdir "profile_img/thumbs/";   // Path To Thumbnails Directory 
    $twidth "125";   // Maximum Width For Thumbnail Images 
    $theight "100";   // Maximum Height For Thumbnail Images 

    if (!isset($_GET['subpage'])) {   // Image Upload Form Below   ?> 
      <form method="post" action="addphoto.php?subpage=upload" enctype="multipart/form-data"> 
       File:<br /> 
      <input type="file" name="imagefile" class="form"> 
      <br /><br /> 
      <input name="submit" type="submit" value="Sumbit" class="form">  <input type="reset" value="Clear" class="form"> 
      </form> 
    <? } else  if (isset($_GET['subpage']) && $_GET['subpage'] == 'upload') {   // Uploading/Resizing Script 
      
    $url $_FILES['imagefile']['name'];   // Set $url To Equal The Filename For Later Use 
      
    if ($_FILES['imagefile']['type'] == "image/jpg" || $_FILES['imagefile']['type'] == "image/jpeg" || $_FILES['imagefile']['type'] == "image/pjpeg") { 
        
    $file_ext strrchr($_FILES['imagefile']['name'], '.');   // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php 
        
    $copy copy($_FILES['imagefile']['tmp_name'], "$idir$_FILES['imagefile']['name']);   // Move Image From Temporary Location To Permanent Location 
        
    if ($copy) {   // If The Script Was Able To Copy The Image To It's Permanent Location 
          
    print 'Image uploaded successfully.<br />';   // Was Able To Successfully Upload Image 
          
    $simg imagecreatefromjpeg("$idir$url);   // Make A New Temporary Image To Create The Thumbanil From 
          
    $currwidth imagesx($simg);   // Current Image Width 
          
    $currheight imagesy($simg);   // Current Image Height 
          
    if ($currheight $currwidth) {   // If Height Is Greater Than Width 
             
    $zoom $twidth $currheight;   // Length Ratio For Width 
             
    $newheight $theight;   // Height Is Equal To Max Height 
             
    $newwidth $currwidth $zoom;   // Creates The New Width 
          
    } else {    // Otherwise, Assume Width Is Greater Than Height (Will Produce Same Result If Width Is Equal To Height) 
            
    $zoom $twidth $currwidth;   // Length Ratio For Height 
            
    $newwidth $twidth;   // Width Is Equal To Max Width 
            
    $newheight $currheight $zoom;   // Creates The New Height 
          

          
    $dimg imagecreate($newwidth$newheight);   // Make New Image For Thumbnail 
          
    imagetruecolortopalette($simgfalse256);   // Create New Color Pallete 
          
    $palsize ImageColorsTotal($simg); 
          for (
    $i 0$i $palsize$i++) {   // Counting Colors In The Image 
           
    $colors ImageColorsForIndex($simg$i);   // Number Of Colors Used 
           
    ImageColorAllocate($dimg$colors['red'], $colors['green'], $colors['blue']);   // Tell The Server What Colors This Image Will Use 
          

          
    imagecopyresized($dimg$simg0000$newwidth$newheight$currwidth$currheight);   // Copy Resized Image To The New Image (So We Can Save It) 
          
    imagejpeg($dimg"$tdir$url);   // Saving The Image 
          
    imagedestroy($simg);   // Destroying The Temporary Image 
          
    imagedestroy($dimg);   // Destroying The Other Temporary Image 
          
    print 'Image thumbnail created successfully.';   // Resize successful 
        
    } else { 
          print 
    '<font color="#FF0000">ERROR: Unable to upload image.</font>';   // Error Message If Upload Failed 
        

      } else { 
        print 
    '<font color="#FF0000">ERROR: Wrong filetype (has to be a .jpg or .jpeg.)';   // Error Message If Filetype Is Wrong 
        
    print '.</font>'
      } 
    ?>
     
  2. Cabbit thread starter macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland
    #2
    Then i need to add this in the following page, however the submit buttons are conflicting with each other.

    PHP:
    <?php
    include("include/session.php");
    ?>
    <?php
    $usrname 
    $session->username;
    $numbers $database->getNumMembers();
    ?>
    <?php
    include('includes-blocks/scripts.php');
    ?>
    <script src="AC_RunActiveContent.js" language="javascript"></script>
    <script language="javascript" type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
    <script language="javascript" type="text/javascript">
    tinyMCE.init({
        mode : "textareas",
        theme : "simple"
    });
    </script>
    </head>
    <body>
    <div id="container">
    <?
    if($session->logged_in){
    include(
    'includes-blocks/header.php');
    }
    else{
    include(
    'includes-blocks/header_notlogin.php');
    }
    ?>
    <div id="Layer_content">
    <?php
    include('includes-blocks/sidebar.php');
    ?>
    <br />
    <div id="content_outer">
    <div>
    <?
    /* Requested Username error checking */
    $req_user trim($_GET['user']);
    if(!
    $req_user || strlen($req_user) == ||
       !
    eregi("^([0-9a-z])+$"$req_user) ||
       !
    $database->usernameTaken($req_user)){
       die(
    "Username not registered");
    }
    /* Display requested user information */
    $req_user_info $database->getUserInfo($req_user);
    ?>
    <?php
    // do stuff //
    $sql mysql_query("SELECT * FROM users WHERE username = '$usrname'");
    $row mysql_fetch_row($sql);
    ?>
    <?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    '<img src="images/content/story_top.png" align="bottom" alt="cont_top" />';
    }
    Else {
        print 
    '<img src="images/content/home_page.png" align="bottom" alt="cont_top" />';

    }
    ?>
    </div>
    <div id="content_decor">
    <div id="content">
    <div id="contentarea">
    <?php
    if($session->logged_in){
    ?>
    <?php
    print "<form action=\"edit/profileedit.php?username=$row[0]\" method=\"post\">";
    ?>
    <div>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td width="94%" class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "story_title";
    }
    Else {
        print 
    "page_title";

    }
    ?>">Profile: <?php echo "".$req_user_info['username'].""?></td>
        <td width="6%" class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "story_title";
    }
    Else {
        print 
    "page_title";

    }
    ?>"><?php
    if ($req_user_info['class'] == 'Baby'){ 
    ?>
    <select name="class" id="class">
      <option value="Baby">Baby</option>
      <option value="Carer">Carer</option>
      <option value="Furry">Furry</option>
    </select>
    <?php
    }
    Elseif (
    $req_user_info['class'] == 'Carer'){
    ?>
    <select name="class" id="class">
      <option value="Carer">Carer</option>
      <option value="Baby">Baby</option>
      <option value="Furry">Furry</option>
    </select>
    <?php
    }
    Elseif (
    $req_user_info['class'] == 'Furry'){
    ?>
    <select name="class" id="class">
      <option value="Furry">Furry</option>
      <option value="Baby">Baby</option>
      <option value="Carer">Carer</option>
    </select>
    <?php
    }
    Else{
    ?>
    <select name="class" id="class">
      <option value="Baby">Baby</option>
      <option value="Furry">Furry</option>
      <option value="Carer">Carer</option>
    </select>
    <?php
    }
    ?>
    </td>
        </tr>
      <tr>
        <td class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "profile_subtitle";
    }
    Else {
        print 
    "boyprofile_subtitle";

    }
    ?>"><?php
    if ($req_user_info['userlevel'] == 9) { 
        print 
    "Admin"
    }
    Else {
        print 
    "Member";
    }
    ?></td>
    <td class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "profile_subtitle";
    }
    Else {
        print 
    "boyprofile_subtitle";

    }
    ?>">
    </td>
        </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td width="85%" class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "pink";
    }
    Else {
        print 
    "home_submenu2";

    }
    ?>"><br />Msn: <input type="text" name="msn" size="30" value="<?php print "$row[22]"?>" /><br />Yahoo: <input type="text" name="yahoo" size="30" value="<?php print "$row[23]"?>" /><br />iChat: <input type="text" name="ichat" size="30" value="<?php print "$row[24]"?>" /><br />e-mail: <?php echo "".$req_user_info['email'].""?><br /></td>
        <td width="15%" class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "pink";
    }
    Else {
        print 
    "home_submenu2";

    }
    ?>">


    UPLOADER GOES HERE....



    PHP:
    </td>
      </tr>
    </table>
    </div>
    <div class="profileabout">
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "profile_title";
    }
    Else {
        print 
    "boyprofile_title";

    }
    ?>" width="100%">About Me: </td>
        </tr>
      <tr>
        <td>
          <textarea name="about" rows="4" cols="52" ><?php
    print nl2br($row[15]);?></textarea>
          </td>
      </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "profile_title";
    }
    Else {
        print 
    "boyprofile_title";

    }
    ?>" width="100%">Hobby's: </td>
        </tr>
      <tr>
        <td>
    <textarea name="hobbys" rows="3" cols="52" ><?php
    print nl2br($row[21]);?></textarea>  </tr>
    </table>
    <div>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "profile_title";
    }
    Else {
        print 
    "boyprofile_title";

    }
    ?>" width="100%">Seeking: </td>
        </tr>
      <tr>
        <td>
          <input type="text" name="seeking" value="<?php print "$row[13]"?>" />
    </td>
      </tr>
      <tr>
          <td>
          <textarea name="other" rows="5" cols="52" ><?php
    print nl2br($row[14]);?></textarea>
      </tr>
    </table>
    </div>
    <div>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "profile_title";
    }
    Else {
        print 
    "boyprofile_title";

    }
    ?>" width="100%">My interests: </td>
        </tr>
      <tr>
        <td>
          <textarea name="interests" rows="5" cols="52" ><?php
    print nl2br($row[20]);?></textarea>
      </tr>
    </table>
    </div>
    <div>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "profile_title";
    }
    Else {
        print 
    "boyprofile_title";

    }
    ?>" width="100%">My Friends: </td>
        </tr>
      <tr>
        <td>
          Coming Soon</td>
      </tr>
    </table>
    </div>
    </div>
    <div class="profileaboutsm">
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "profile_title";
    }
    Else {
        print 
    "boyprofile_title";

    }
    ?>">My Stats:</td>
        </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="39%">Age:</td>
            <td width="61%"><input type="text" name="age" value="<?php print "$row[6]"?>" />
    </td>
        </tr>
          <tr class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "pink";
    }
    Else {
        print 
    "blue";

    }
    ?>">
            <td>Gender:</td>
            <td>
    <?php
    if ($req_user_info['gender'] == 'Female'){ 
    ?>
    <select name="gender" id="gender">
      <option value="Female">Female</option>
      <option value="Male">Male</option>
    </select>
    <?php
    }
    Else {
    ?>
    <select name="gender" id="gender">
      <option value="Male">Male</option>
      <option value="Female">Female</option>
    </select>
    <?php
    }
    ?>
    </td>
          </tr>
          <tr>
            <td>Location:</td>
            <td><input type="text" name="location" value="<?php print "$row[9]"?>" />
    </td>
          </tr>
          <tr class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "pink";
    }
    Else {
        print 
    "blue";

    }
    ?>">
            <td>Height:</td>
            <td><input type="text" name="height" value="<?php print "$row[10]"?>" /></td>
          </tr>
          <tr>
            <td>Eye Colour:</td>
            <td><input type="text" name="eyes" value="<?php print "$row[11]"?>" /></td>
          </tr>
          <tr class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "pink";
    }
    Else {
        print 
    "blue";

    }
    ?>">
            <td>Hair Colour:</td>
            <td><input type="text" name="hair" value="<?php print "$row[12]"?>" /></td>
          </tr>
          <tr>
            <td>Race:</td>
            <td><input type="text" name="race" value="<?php print "$row[8]"?>" /></td>
          </tr>
          <tr class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "pink";
    }
    Else {
        print 
    "blue";

    }
    ?>">
            <td>Occupation:</td>
            <td><input type="text" name="ocupation" value="<?php print "$row[18]"?>" />
    </td>
          </tr>
        </table>
        <div>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "profile_title";
    }
    Else {
        print 
    "boyprofile_title";

    }
    ?>">Profile Image: </td>
        </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td><img src="profile_img/<?php echo "".$req_user_info['facepic'].""?>" alt="facepic" width="100%" /></td>
      </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "profile_title";
    }
    Else {
        print 
    "boyprofile_title";

    }
    ?>">Save Changes: </td>
        </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td>      <input type="submit" value="Submit"></form>        
    </td>
      </tr>
    </table>

    </div>
    </div>
    <?php
    }
    else{
    include(
    "includes-blocks/frontpage.html");} 
    ?>
    </div>
    </div>
    </div>
    <img src="images/content/content_bottom.png" alt="cont_btm" />
    </div>
    <div id="footer">
    <img src="images/content/page_footer.png" alt="footer" />
    </div>
    </div></div>
    [/PHP]
     
  3. Cabbit thread starter macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland
    #3
    ok so i have now seperated the functions a little

    so there is now a edit page,

    PHP:
    <?php
    if($session->logged_in){
    ?>
    <?php
    print "<form action=\"edit/profileedit.php?username=$row[0]\" method=\"post\">";
    ?>
    <div>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td width="94%" class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "story_title";
    }
    Else {
        print 
    "page_title";

    }
    ?>">Profile: <?php echo "".$req_user_info['username'].""?></td>
        <td width="6%" class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "story_title";
    }
    Else {
        print 
    "page_title";

    }
    ?>"><?php
    if ($req_user_info['class'] == 'Baby'){ 
    ?>
    <select name="class" id="class">
      <option value="Baby">Baby</option>
      <option value="Carer">Carer</option>
      <option value="Furry">Furry</option>
    </select>
    <?php
    }
    Elseif (
    $req_user_info['class'] == 'Carer'){
    ?>
    <select name="class" id="class">
      <option value="Carer">Carer</option>
      <option value="Baby">Baby</option>
      <option value="Furry">Furry</option>
    </select>
    <?php
    }
    Elseif (
    $req_user_info['class'] == 'Furry'){
    ?>
    <select name="class" id="class">
      <option value="Furry">Furry</option>
      <option value="Baby">Baby</option>
      <option value="Carer">Carer</option>
    </select>
    <?php
    }
    Else{
    ?>
    <select name="class" id="class">
      <option value="Baby">Baby</option>
      <option value="Furry">Furry</option>
      <option value="Carer">Carer</option>
    </select>
    <?php
    }
    ?>
    </td>
        </tr>
      <tr>
        <td class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "profile_subtitle";
    }
    Else {
        print 
    "boyprofile_subtitle";

    }
    ?>"><?php
    if ($req_user_info['userlevel'] == 9) { 
        print 
    "Admin"
    }
    Else {
        print 
    "Member";
    }
    ?></td>
    <td class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "profile_subtitle";
    }
    Else {
        print 
    "boyprofile_subtitle";

    }
    ?>">
    </td>
        </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td width="85%" class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "pink";
    }
    Else {
        print 
    "home_submenu2";

    }
    ?>"><br />Msn: <input type="text" name="msn" size="30" value="<?php print "$row[22]"?>" /><br />Yahoo: <input type="text" name="yahoo" size="30" value="<?php print "$row[23]"?>" /><br />iChat: <input type="text" name="ichat" size="30" value="<?php print "$row[24]"?>" /><br />e-mail: <?php echo "".$req_user_info['email'].""?><br /></td>
        <td width="15%" class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "pink";
    }
    Else {
        print 
    "home_submenu2";

    }
    ?>">
    File:<br /> 
    <input type="file" name="imagefile" class="form">
    </td>
      </tr>
    </table>
    </div>
    <div class="profileabout">
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "profile_title";
    }
    Else {
        print 
    "boyprofile_title";

    }
    ?>" width="100%">About Me: </td>
        </tr>
      <tr>
        <td>
          <textarea name="about" rows="4" cols="52" ><?php
    print nl2br($row[15]);?></textarea>
          </td>
      </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "profile_title";
    }
    Else {
        print 
    "boyprofile_title";

    }
    ?>" width="100%">Hobby's: </td>
        </tr>
      <tr>
        <td>
    <textarea name="hobbys" rows="3" cols="52" ><?php
    print nl2br($row[21]);?></textarea>  </tr>
    </table>
    <div>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "profile_title";
    }
    Else {
        print 
    "boyprofile_title";

    }
    ?>" width="100%">Seeking: </td>
        </tr>
      <tr>
        <td>
          <input type="text" name="seeking" value="<?php print "$row[13]"?>" />
    </td>
      </tr>
      <tr>
          <td>
          <textarea name="other" rows="5" cols="52" ><?php
    print nl2br($row[14]);?></textarea>
      </tr>
    </table>
    </div>
    <div>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "profile_title";
    }
    Else {
        print 
    "boyprofile_title";

    }
    ?>" width="100%">My interests: </td>
        </tr>
      <tr>
        <td>
          <textarea name="interests" rows="5" cols="52" ><?php
    print nl2br($row[20]);?></textarea>
      </tr>
    </table>
    </div>
    <div>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "profile_title";
    }
    Else {
        print 
    "boyprofile_title";

    }
    ?>" width="100%">My Friends: </td>
        </tr>
      <tr>
        <td>
          Coming Soon</td>
      </tr>
    </table>
    </div>
    </div>
    <div class="profileaboutsm">
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "profile_title";
    }
    Else {
        print 
    "boyprofile_title";

    }
    ?>">My Stats:</td>
        </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="39%">Age:</td>
            <td width="61%"><input type="text" name="age" value="<?php print "$row[6]"?>" />
    </td>
        </tr>
          <tr class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "pink";
    }
    Else {
        print 
    "blue";

    }
    ?>">
            <td>Gender:</td>
            <td>
    <?php
    if ($req_user_info['gender'] == 'Female'){ 
    ?>
    <select name="gender" id="gender">
      <option value="Female">Female</option>
      <option value="Male">Male</option>
    </select>
    <?php
    }
    Else {
    ?>
    <select name="gender" id="gender">
      <option value="Male">Male</option>
      <option value="Female">Female</option>
    </select>
    <?php
    }
    ?>
    </td>
          </tr>
          <tr>
            <td>Location:</td>
            <td><input type="text" name="location" value="<?php print "$row[9]"?>" />
    </td>
          </tr>
          <tr class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "pink";
    }
    Else {
        print 
    "blue";

    }
    ?>">
            <td>Height:</td>
            <td><input type="text" name="height" value="<?php print "$row[10]"?>" /></td>
          </tr>
          <tr>
            <td>Eye Colour:</td>
            <td><input type="text" name="eyes" value="<?php print "$row[11]"?>" /></td>
          </tr>
          <tr class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "pink";
    }
    Else {
        print 
    "blue";

    }
    ?>">
            <td>Hair Colour:</td>
            <td><input type="text" name="hair" value="<?php print "$row[12]"?>" /></td>
          </tr>
          <tr>
            <td>Race:</td>
            <td><input type="text" name="race" value="<?php print "$row[8]"?>" /></td>
          </tr>
          <tr class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "pink";
    }
    Else {
        print 
    "blue";

    }
    ?>">
            <td>Occupation:</td>
            <td><input type="text" name="ocupation" value="<?php print "$row[18]"?>" />
    </td>
          </tr>
        </table>
        <div>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "profile_title";
    }
    Else {
        print 
    "boyprofile_title";

    }
    ?>">Profile Image: </td>
        </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td><img src="profile_img/<?php echo "".$req_user_info['facepic'].""?>" alt="facepic" width="100%" /></td>
      </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td class="<?php
    if ($req_user_info['gender'] == 'Female'){ 
        print 
    "profile_title";
    }
    Else {
        print 
    "boyprofile_title";

    }
    ?>">Save Changes: </td>
        </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td>      <input name="submit" type="submit" value="Submit"></form>        
    </td>
      </tr>
    </table>
    And this is the uploader, well the not working uploader, i need the image to upload and add the $username to the image and then upload the image titile to the database.

    PHP:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Uploading</title>
    <meta http-equiv="Refresh" content="3;URL=../user_profile.php?user=<?php echo $_GET['username'?>" />
    <link rel="stylesheet" href="../stylesheet.css" type="text/css" />
    </head>
    <body>
    <div id="container">
    <?
    //database connect //
    include('../include/session.php');
    //header//
    if($session->logged_in){
    include(
    '../includes-blocks/header.php');
    }
    else{
    include(
    '../includes-blocks/header_notlogin.php');
    }
    ?>
    <div id="Layer_content">
    <br />
    <table width="100%">
    <tr>
    <td align="center">
    <?php 
    $idir 
    "profile_img/";   // Path To Images Directory 
    $tdir "profile_img/thumbs/";   // Path To Thumbnails Directory 
    $twidth "80";   // Maximum Width For Thumbnail Images 
    $theight "100";   // Maximum Height For Thumbnail Images 
    if (!isset($_GET['subpage'])) {   // Image Upload Form Below   ?>  
    <? } else  if (isset($_GET['subpage']) && $_GET['subpage'] == 'upload') {   // Uploading/Resizing Script 
      
    $url $_FILES['imagefile']['name'];   // Set $url To Equal The Filename For Later Use 
      
    if ($_FILES['imagefile']['type'] == "image/jpg" || $_FILES['imagefile']['type'] == "image/jpeg" || $_FILES['imagefile']['type'] == "image/pjpeg") { 
        
    $file_ext strrchr($_FILES['imagefile']['name'], '.');   // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php 
        
    $copy copy($_FILES['imagefile']['tmp_name'], "$idir$_FILES['imagefile']['name']);   // Move Image From Temporary Location To Permanent Location 
        
    if ($copy) {   // If The Script Was Able To Copy The Image To It's Permanent Location 
          
    print 'Image uploaded successfully.<br />';   // Was Able To Successfully Upload Image 
          
    $simg imagecreatefromjpeg("$idir$url);   // Make A New Temporary Image To Create The Thumbanil From 
          
    $currwidth imagesx($simg);   // Current Image Width 
          
    $currheight imagesy($simg);   // Current Image Height 
          
    if ($currheight $currwidth) {   // If Height Is Greater Than Width 
             
    $zoom $twidth $currheight;   // Length Ratio For Width 
             
    $newheight $theight;   // Height Is Equal To Max Height 
             
    $newwidth $currwidth $zoom;   // Creates The New Width 
          
    } else {    // Otherwise, Assume Width Is Greater Than Height (Will Produce Same Result If Width Is Equal To Height) 
            
    $zoom $twidth $currwidth;   // Length Ratio For Height 
            
    $newwidth $twidth;   // Width Is Equal To Max Width 
            
    $newheight $currheight $zoom;   // Creates The New Height 
          

          
    $dimg imagecreate($newwidth$newheight);   // Make New Image For Thumbnail 
          
    imagetruecolortopalette($simgfalse256);   // Create New Color Pallete 
          
    $palsize ImageColorsTotal($simg); 
          for (
    $i 0$i $palsize$i++) {   // Counting Colors In The Image 
           
    $colors ImageColorsForIndex($simg$i);   // Number Of Colors Used 
           
    ImageColorAllocate($dimg$colors['red'], $colors['green'], $colors['blue']);   // Tell The Server What Colors This Image Will Use 
          

          
    imagecopyresized($dimg$simg0000$newwidth$newheight$currwidth$currheight);   // Copy Resized Image To The New Image (So We Can Save It) 
          
    imagejpeg($dimg"$tdir$url);   // Saving The Image 
          
    imagedestroy($simg);   // Destroying The Temporary Image 
          
    imagedestroy($dimg);   // Destroying The Other Temporary Image 
          
    print 'Image thumbnail created successfully.';   // Resize successful 
        
    } else { 
          print 
    '<font color="#FF0000">ERROR: Unable to upload image.</font>';   // Error Message If Upload Failed 
        

      } else { 
        print 
    '<font color="#FF0000">ERROR: Wrong filetype (has to be a .jpg or .jpeg.)';   // Error Message If Filetype Is Wrong 
        
    print '.</font>'
      } 
    ?>
    <?php
    //grab data from form
    $id $_GET['username'];
    $age $_POST['age'];
    $gender $_POST['gender'];
    $race $_POST['race'];
    $location $_POST['location'];
    $height $_POST['height'];
    $eyes $_POST['eyes'];
    $hair $_POST['hair'];
    $class $_POST['class'];
    $seeking $_POST['seeking'];
    $other $_POST['other'];
    $about $_POST['about'];
    $ocupation $_POST['ocupation'];
    $interests $_POST['interests'];
    $hobbys $_POST['hobbys'];
    $msn $_POST['msn'];
    $yahoo $_POST['yahoo'];
    $ichat $_POST['ichat'];
    $query "UPDATE `users` SET age = '$age', class = '$class', gender = '$gender', race = '$race', location = '$location', height = '$height', eyes = '$eyes', hair = '$hair', seeking = '$seeking', other = '$other', about = '$about', ocupation = '$ocupation', interests = '$interests', hobbys = '$hobbys', msn ='$msn', yahoo = '$yahoo', ichat = '$ichat' WHERE username = '$id'";
    if ( !
    mysql_query$query ) ) { 
        echo 
    "There was an error, please try again."
        echo 
    mysql_error( ); 

    else 
    echo 
    "Uploading Please Wait...";
    ?>
    </td>
    </tr>
    <tr>
    <td align="center">
    <img src="../ajax-loader.gif" alt="loader" />
    <td>
    </tr>
    </table>
    <div id="footer">
    <img src="../images/content/page_footer.png" alt="footer" />
    </div>
    </div></div>
    </body>
    </html>
     

Share This Page