[Solved] HOW TO MAKE A DYNAMIC PROFILE PAGE? [closed]


Well, for such small tasks no CMS (I mean WP or Drupal) is necessarily needed – customizing one for your needs will me much more painful, than adding a few PHP lines to your HTML files.

To make your website able to get data, you will have to make it perform some server-side operations. This is most often done by PHP scripts (of which you could have heard of). If you are familiar with it, you can just skip the next paragraph.

PHP is a really easy and powerful language to learn, but bear in mind that if you learn some bad practices at the very beginning, you will be having a bad time trying to get rid of them later. But for this single purpose, you should take look at PHP tutorial at Codecademy (well, SO does not allow me to post more than 2 links so far, so you will have to google it by yourself :(). By the way, there are lots of tutorials on Youtube for guys just like you – just type in something like “php cms tutorial” and they will show up – but they might be at least a little confusing for people, who have never experienced PHP before.

First of all, determine which part of your website will be affected by variables. In these places you will have to put PHP’s echoes, such as

<?php echo $name ?>

<?php echo $description ?>

or, in case of an image:

<img alt="some alt text" src="https://stackoverflow.com/questions/23575362/<?php echo $image_location ?>">

If you have it, your next step will be writing a PHP code, that will perform:

  1. Reading from a data source (text file, database)
  2. Assigning each data part to a specific variable
  3. echo ing it in the HTML file

Sound pretty easy. So you have an image, a title, and a description. Well, title and a description may be kept in a single text file. The content inside will be separated by explode() function, for example if you keep your data in the x.txt file, that you will read in to a variable by the file_get_contents() function:

Name|||Bio

the explode("|||", $data) function will return an array:

[0] => "Name"
[1] => "Bio"

Well, of course this is not the most elegant way, but definitely the easiest. Anyway, it covers the reading part.

For the writing part, that will be mostly used by your client, you should make a set of HTML files containing forms, that will forward to a PHP script executing validating, escaping and writing instructions. Get familar with superglobal array $_POST, functions such as htmlspecialchars(), nl2br(), fwrite(). You would also like to set a some kind of an authentication. For image upload, just check out file upload tutorial. Having your files location, you can store it in your files, and then put it in the src attribute of your img tag.

2

solved HOW TO MAKE A DYNAMIC PROFILE PAGE? [closed]