By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,462 Members | 1,057 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,462 IT Pros & Developers. It's quick & easy.

Displaying Images

P: 12
I have a website that allows users to regsiter, login and then create/update their user profiles. Users are allowed to also upload a profile picture, but the next time a user logs in the profile picture sometimes has some associated display problems i.e. it could happen that the picture does not display properly, is missing or has some other problem. This problem seems to be random in nature. Is there any way of making the display of this picture better? My website is using HTML/PHP/MySQL for its development.
Jun 2 '12 #1
Share this Question
Share on Google+
6 Replies


Dormilich
Expert Mod 5K+
P: 8,639
how do you save the pictures exactly?
Jun 4 '12 #2

P: 12
See below table containing image coding...any ideas?

Expand|Select|Wrap|Line Numbers
  1. <table width="100%" border="0" cellspacing="0" cellpadding="4">
  2.                         <tr>
  3.                           <td width="15%" valign="top"><b>User Type</b>&nbsp;<span title="This field is required" class="form-required">*</span></td>
  4.                           <td width="85%" valign="top"><table width="50%" border="0" cellspacing="0" cellpadding="3">
  5.                             <tr>
  6.                               <td width="18%"><b><label for="_UserType_P">Private User</label></b></td>
  7.                               <td width="9%"><input id="_UserType_P" type="radio" name="_UserType" value="P" <?php echo (($_UserType=='P') ? ' checked="checked"' : ''); ?> onclick="javascript:fnToggleBus(0);" /></td>
  8.                               <td width="22%"><b><label for="_UserType_B">Business User</label></b></td>
  9.                               <td width="51%"><input id="_UserType_B" type="radio" name="_UserType" value="B" <?php echo (($_UserType=='B') ? ' checked="checked"' : ''); ?> onclick="javascript:fnToggleBus(1);" /></td>
  10.                             </tr>
  11.                           </table></td>
  12.                         </tr>
  13.                         <tr>
  14.                           <td valign="top"><strong>Profile Picture </strong></td>
  15.                           <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
  16.                               <tr>
  17.                                 <td width="9%"><iframe id="frmImage" frameborder="0" src="/proc/images.php" <?php echo (($_SESSION['User']['Picture']!='' || count($_SERVER['Images'])>0) ? ' height="200"' : ' height="50"'); ?>></iframe></td>
  18.                                 <td width="91%"></td>
  19.                               </tr>
  20.                             </table></td>
  21.                         </tr>
  22.                         <tr>
  23.                           <td valign="top"><strong>Username</strong></td>
  24.                           <td valign="top"><input class="form-text" id="_Email2" type="text" name="_Email2" value="<?php echo $_Username; ?>" maxlength="255" /></td>
  25.                         </tr>
  26.                         <tr>
  27.                             <td valign="top"><b>Login Email</b>&nbsp;<span title="This field is required" class="form-required">*</span></td>
  28.                             <td valign="top"><input class="form-text" id="_Email" type="text" name="_Email" value="<?php echo $_Email; ?>" maxlength="255" /></td>
  29.                         </tr>
  30.                         <tr>
  31.                           <td valign="top"><b>Password</b></td>
  32.                           <td valign="top"><input class="form-text" id="_Password" type="password" name="_Password" maxlength="100" value="0123456789" /></td>
  33.                         </tr>
  34.                         <tr>
  35.                           <td valign="top"><b>Name</b>&nbsp;<span title="This field is required" class="form-required">*</span></td>
  36.                           <td valign="top"><input class="form-text" id="_Name" type="text" name="_Name" value="<?php echo $_Name; ?>" maxlength="100" /></td>
  37.                         </tr>
  38.                         <tr>
  39.                           <td valign="top"><b>Surname</b>&nbsp;<span title="This field is required" class="form-required">*</span></td>
  40.                           <td valign="top"><input class="form-text" id="_Surname" type="text" name="_Surname" value="<?php echo $_Surname; ?>" maxlength="100" /></td>
  41.                         </tr>
  42.                         <tr>
  43.                           <td valign="top"><b>Date of birth</b>&nbsp;<span title="This field is required" class="form-required">*</span></td>
  44.                           <td valign="top"><select name="_DOB_d" id="_DOB_d" style="width:auto;">
  45.                             <option value="" selected="selected">Day</option>
  46.                             <?php
  47.                             for ($d=1; $d<=31; $d++){
  48.                                 echo '<option value="' . $d . '"';
  49.                                 if($_DOB_d == $d){
  50.                                     echo ' selected="selected"';
  51.                                 }
  52.                                 echo '>' . $d . '</option>';
  53.                             }
  54.                             ?>
  55.                         </select>&nbsp;<select name="_DOB_m" id="_DOB_m" style="width:auto;">
  56.                             <option value="" selected="selected">Month</option>
  57.                             <?php
  58.                             foreach(Array(1 => 'January', 'Febuary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December') as $m => $mM){
  59.                                 echo '<option value="' . $m . '"';
  60.                                 if($_DOB_m == $m){
  61.                                     echo ' selected="selected"';
  62.                                 }
  63.                                 echo '>' . $mM . '</option>';
  64.                             }
  65.                             ?>
  66.                         </select>&nbsp;<select name="_DOB_y" id="_DOB_y" style="width:auto;">
  67.                             <option value="" selected="selected">Year</option>
  68.                             <?php
  69.                             for($y=2011; $y>=1900; $y--){
  70.                                 echo '<option value="' . $y . '"';
  71.                                 if($_DOB_y == $y){
  72.                                     echo ' selected="selected"';
  73.                                 }
  74.                                 echo '>' . $y . '</option>';
  75.                             }
  76.                             ?>
  77.                         </select>                        </td></tr>
  78.                         <tr>
  79.                             <td valign="top"><b>Gender</b>&nbsp;<span title="This field is required" class="form-required">*</span></td><td valign="top"><label>Male&nbsp;<input id="_Gender" type="radio" name="_Gender" value="M" <?php echo (($_Gender=='M') ? ' checked="checked"' : ''); ?> /></label>&nbsp;&nbsp;<label>Female<input id="_Gender" type="radio" name="_Gender" value="F" <?php echo (($_Gender=='F') ? ' checked="checked"' : ''); ?> /></label></td>
  80.                         </tr>
  81.                         <tr>
  82.                             <td valign="top"><b>Interests</b></td><td valign="top">
  83.                             <select name="_Interest" id="_Interest">
  84.                                 <option value="" selected="selected">Select Interest</option>
  85.                                 <?php
  86.                                 $rsInterest = $oConn->query("SELECT ID,Description FROM TblInterest ORDER BY Description");
  87.                                 foreach($rsInterest as $aInterest){
  88.                                     echo '<option value="' . $aInterest[0] . '"' . (($_Interest == $aInterest[0]) ? ' selected="selected"' : '') . '>' . $aInterest[1] . '</option>';
  89.                                 }
  90.                                 ?>
  91.                             </select>            
  92.                             </td>
  93.                         </tr>
  94.     </table>
Jun 4 '12 #3

Dormilich
Expert Mod 5K+
P: 8,639
I may be blind, but I’m not seeing any code that saves the image.
Jun 4 '12 #4

P: 12
Please see the piece of code extracted from the above:
Expand|Select|Wrap|Line Numbers
  1. <td width="9%"><iframe id="frmImage" frameborder="0" src="/proc/images.php" <?php echo (($_SESSION['User']['Picture']!='' || count($_SERVER['Images'])>0) ? ' height="200"' : ' height="50"'); ?>></iframe></td> 
  2.  
Also please see attached print-screen pic, which shows an example display error. Where the red rectangle is there should be a profile picture displayed, but it is missing...

What do you think the best way of saving and displaying a profile pic should be?

This is all the information I have at the moment, the rest will be with the developer...
Attached Images
File Type: jpg Profile Pic Error.jpg (28.2 KB, 145 views)
Jun 5 '12 #5

Dormilich
Expert Mod 5K+
P: 8,639
why in the world would you display an image by an <iframe>? that’s what the <img> tag is for. and for upload I’d just use a file upload field ...

and unless I know what images.php does, how am I supposed to know whether it is wrong or right what you see?
Jun 5 '12 #6

P: 12
Apologies for the delay. Please check out the info below contained in the file "images.php" and let me know if you can maybe pic up a problem with regards to the profile image framing?

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. @session_start();
  4. /*echo '<pre>';
  5. print_r($_SESSION);
  6. echo '</pre>';*/
  7.  
  8. $sError ='';
  9. if(isset($_SESSION['uploadError'])){
  10.     $sError .= $_SESSION['uploadError'];
  11. }
  12. if(isset($_SESSION['Images'])){$Images = $_SESSION['Images'];}
  13. else{$Images = Array();}
  14.  
  15. echo "
  16. <html>
  17.     <head>
  18.         <style>*{padding:0; margin:0; font:Normal 13px Tahoma;} table.gallery{padding-right:10px;}table.gallery td{vertical-align:bottom;}table.gallery td{padding:5px;}table.gallery td div{padding-bottom:3px; text-align:center;}</style>
  19.     </head>
  20. <body style='background-color:#f0f0f0;'><form method='post' enctype='multipart/form-data'>\n";
  21.  
  22. $iImgCount = count($Images);
  23. if($iImgCount<1){
  24.     echo"<input name='flImage' type='file' onchange='javascript:fnAddImage()' /><br />";
  25.     echo"<script language='javascript'>function fnAddImage(){var f=document.forms[0];if(f.flImage.value.length!=0){f.action='default.php';f.submit();}}</script>\n";
  26. }
  27.  
  28. if($iImgCount>0){
  29.     if(count($Images)>0){
  30.         $sImage = 'Photos/' . $Images[0] . "_t.jpg";
  31.         $_SERVER['User']['Picture'] = $Images[0];
  32.         echo "<br /><table border='0' class='gallery'><tr><td><img src='/$sImage' width='150' /></td></tr><tr><td align='center'><a href='images_rem.php?id=0' title='Remove'>Remove</a></td></tr></table>\n";
  33.     }
  34.     else{
  35.         echo "<table class='gallery' cellspacing='10'><tr>";
  36.         $iCount = 0;
  37.         foreach($Images as $i => $Image){
  38.             $sImage = 'Photos/' . $Image . "_t.jpg";
  39.             $iCount++;
  40.             echo "<td><div class='item'><img src='/$sImage' width='150' /></div><div><a href='images_rem.php?id=$i'>Remove</a></div></td>\n";
  41.             if($iCount>=2){
  42.                 echo '</tr><tr>';
  43.                 $iCount=0;
  44.             }
  45.         }
  46.         echo "</table>";
  47.     }
  48. }
  49.  
  50. echo "</form>";
  51. echo ($sError !='') ? "<div style='color:red;'>$sError</div>\n" : '';
  52. echo "<script language='javascript'>window.onload=function(){window.parent.document.getElementById('frmImage').height=(window.document.body.scrollHeight+20);}</script></body</html>";
  53.  
  54. if(isset($_SESSION['uploadError'])){
  55.     unset($_SESSION['uploadError']);
  56. }
Sep 19 '12 #7

Post your reply

Sign in to post your reply or Sign up for a free account.