imrie Posted July 19, 2007 Share Posted July 19, 2007 Hello,I am making a profile system for my website, and i need a file to be made in the directory "/users/" then i need the file name to be the username (the one that was registered with).So when You press "register" you will have your profile called example: www.website.com/users/"username".If somebody could tell me this code please,Thanks.Ps, In the future i need this file to have content on it already. Some some help with that will be good. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 19, 2007 Share Posted July 19, 2007 Don't make a separate file for each user, have 1 ASP page that reads which user it is, gets their info from the database, and displays it where it needs to go. Most sites do something like that. With a server running Apache you can use some tricks to still get the URL to point to a file with the user's name, but with a server running IIS and ASP I don't think you can do that. Link to comment Share on other sites More sharing options...
imrie Posted July 19, 2007 Author Share Posted July 19, 2007 Can you tell me how i would do that? Link to comment Share on other sites More sharing options...
justsomeguy Posted July 19, 2007 Share Posted July 19, 2007 Have you worked with a database before? Link to comment Share on other sites More sharing options...
imrie Posted July 19, 2007 Author Share Posted July 19, 2007 Yes Link to comment Share on other sites More sharing options...
justsomeguy Posted July 19, 2007 Share Posted July 19, 2007 You need to send the page the ID or username of whichever user to show information for. So the address would look like this:user.asp?id=123You read the id using Request.Querystring, and use the ID to look up the info in the database, then write it wherever you want it on the page. Link to comment Share on other sites More sharing options...
imrie Posted July 19, 2007 Author Share Posted July 19, 2007 Great, thanks so when you click register your username, email, password, name and now an id gets sent to the database. Am i correct?I already have afield called "userid" would that help?And how do i go about creating content on that page?Thanks, Link to comment Share on other sites More sharing options...
justsomeguy Posted July 19, 2007 Share Posted July 19, 2007 You create content the same way you create content on any other page, the only thing special about a dynamic page like this is certain pieces of content (the page title, most notably) are coming from the database. So instead of static text in the <title> tag, you might have a Response.Write statement writing the person's name. Link to comment Share on other sites More sharing options...
imrie Posted July 19, 2007 Author Share Posted July 19, 2007 Ok... Do you have any idea how i could create an interface where each indvidual can edit there profile?So i have a field in the database called id how do i make that a page like id=1, id=2? Link to comment Share on other sites More sharing options...
justsomeguy Posted July 19, 2007 Share Posted July 19, 2007 A page for people to edit the profile is just a normal page with a form on it with a text box for everything that is in the database. Submitting the form would go to a processing page that reads each of the fields and updates the database. There's nothing special you have to do to link each id to the profile page. If you make a link with a certain id on it, the page will read the id and get the data. I'm not sure what the problem is. Link to comment Share on other sites More sharing options...
imrie Posted July 19, 2007 Author Share Posted July 19, 2007 Well, the problem is i am not that savy at webdev, I have a mysql database, what fields would i need to have and what should i have in each field to make this work? Link to comment Share on other sites More sharing options...
justsomeguy Posted July 19, 2007 Share Posted July 19, 2007 The fields are up to you, any piece of information you want to save needs a field. You could have a field for name, birthdate, location, whatever you want to save. Link to comment Share on other sites More sharing options...
imrie Posted July 19, 2007 Author Share Posted July 19, 2007 Is there a way to store images and files on that database? such as an avatar or a download. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 19, 2007 Share Posted July 19, 2007 Save the actual file as normal in a directory you choose, and just save the filename of the file in the database. You can save the binary data in the database, but it will slow things down. Link to comment Share on other sites More sharing options...
imrie Posted July 20, 2007 Author Share Posted July 20, 2007 Ok thanks, so i would have an upload system which would upload the file to a directory (does this file have to be unique, different per user?) How would i also have the image url sent to the database? and show up in the profile? (same applys to the a file)Is it also possible to send the url to another table/database? or is it possible to send the image and download to another location without the need for another database? Link to comment Share on other sites More sharing options...
imrie Posted July 30, 2007 Author Share Posted July 30, 2007 Ok , so i have worked it out that i will use a simple method of a mysql UPDATE command to edit the fields (name, occupation etc.) But the thing i still dont understand is how to save and display an avatar in your profile. Is it possible to have a field where the user can choose an image to upload and save the location and file to a directory an database and display it. If so How?The thing is i know how to do this in theory but not the coding. Thanks for your help Link to comment Share on other sites More sharing options...
justsomeguy Posted July 30, 2007 Share Posted July 30, 2007 Check the FileSystemObject reference on the w3schools site to see how to create or copy a file. If they upload a file, you would copy the uploaded file to whatever directory you want to keep pictures in and save the name of the file with the user's record.As far as uploading goes, ASP does not have built-in support for file uploads. You would need to use a third-party component to handle the upload. The server you're on might already provide one, but if not there are free ones you can use, like freeaspupload. However, when you use an upload component it removes the Request.Form collection, you can no longer access values using Request.Form. Typically you have to access all values using the upload object. I've used freeaspupload before and it worked out pretty well, regardless of the Request object being unavailable. Link to comment Share on other sites More sharing options...
imrie Posted July 31, 2007 Author Share Posted July 31, 2007 would it be easier using php? the only problem with freeaspupload is that it requires permmisions set and i cant do this on a windows server and i am useing a linux one now. Im i being really dumb and does ASP work on linux?Thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted July 31, 2007 Share Posted July 31, 2007 PHP does have native support for file uploading, it is easier with PHP. ASP does not run natively on Linux, you would need to use an emulator if you want to do that. That also requires installing software on the server.But, regardless, you don't need to install or configure anything to use freeaspupload, that's why I like it. You just need to include the file which creates an upload class and use it from there. There is some documentation on how to use it at their site. Link to comment Share on other sites More sharing options...
imrie Posted July 31, 2007 Author Share Posted July 31, 2007 Ok, seems like the asp upload option is too hard, how can i do this with php then?BTW, thanks for helping me all this time. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 31, 2007 Share Posted July 31, 2007 Check here:http://www.php.net/manual/en/features.file-upload.phphttp://www.w3schools.com/php/php_file_upload.asp Link to comment Share on other sites More sharing options...
imrie Posted July 31, 2007 Author Share Posted July 31, 2007 Ok, thanks i now under stand that aspect, but now how do i also save the data to a mysql database? and then i will just need to use a mysql SELECT statment.Thanks, Link to comment Share on other sites More sharing options...
justsomeguy Posted July 31, 2007 Share Posted July 31, 2007 Check the MySQL reference:http://www.php.net/manual/en/ref.mysql.phpYou use mysql_connect and mysql_select_db to connect to the database, and mysql_query will send a query. Check the page for mysql_query to see some examples. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.