Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Reply
 
LinkBack Thread Tools Display Modes
Old 22-04-2011, 10:37 PM   #1 (permalink)
Right Off the Assembly Line
 
Join Date: Apr 2011
Location: BBSR, Orissa
Posts: 34
Red face How to assign default image to user?


I am doing a website using Asp.net(c#)
My requirement is .
when the user registers,a default image should be assigned to him in the database which can be changed later.
suppose this default image is stored within a folder named image and the table name is user_reg & the column name is user_image
How to write code to assign the default image.
binay00713 is offline   Reply With Quote
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 22-04-2011, 11:37 PM   #2 (permalink)
Simply a DIGITian
 
krishnandu.sarkar's Avatar
 
Join Date: Nov 2007
Location: Kolkata
Posts: 2,942
Default Re: How to assign default image to user?

Ok, so when you are registering the user, and inserting the data in database, check if user selected any image, if not then insert user_image into user_reg along with other data.

If you are looking for the concept how to store image in database, store the path of the image.

So if no custom image selected by the user at the time of registration, implicitly insert the default image path in to database.

May be something like

if(imagecontrol.path == "")
{
path = default image path
}
else
{
path = imagecontrol.path
}

Now insert append the path variable while inserting. So it'll insert whatever it contains.
__________________
  • Read The Forum RULES First.
  • Before PM'ing Or Asking Any Questions To Any Mod Read The FAQ's
  • Before Starting A New Thread Read The STICKY THREADS First
  • Before Participating In Bazaar Section Read The BAZAAR RULES
krishnandu.sarkar is online now   Reply With Quote
Old 19-05-2011, 01:54 PM   #3 (permalink)
Right Off the Assembly Line
 
Join Date: May 2011
Posts: 45
Default Re: How to assign default image to user?

Alright if you are using PHP heres what you can do
First make a comnection to the database and if the user has uploaded the image then the user_image column should have some address to the image like "images/userImages/myImage.jpg"
and if its empty we are gonna show the default pic so th ecode could go something like this

if you are into programming you know what 'id' is

$sql = mysql_query("SELECT * FROM users WHERE id='$lid'");

while ($row = mysql_fetch_assoc($sql)){

$location = $row['user_image'];
}

so this will give image location
and if its empty thats

if($location == "")
{
$location = "images/userImages/default/defaultpic.jpg";//address for your default pic
}

and then echo the $location out where the pic is to be displayed
and if the user wants to change it $location will just get updated and if the user will remove the pic it will get null and the user will see the default pic
nishantve1 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by Charan
- by Sarath
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 12:26 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2