How to insert php code into your website?

hello, so im very new to all of this and im having issues with inserting code into the pages. i want my website to have a login and register page, and i have the code, i just dont know how to add it into the website. i also want to know how to change the websites look after you login to the page, so it has more options. can someone help me with this? thank you!

@Supun I know you’re very good at that :stuck_out_tongue_winking_eye:

Will he respond soon? I need to know as soon as possible, since im turning this in as a project this week XP

If you’re counting on him to help you on the whole thing, I recommend you to learn coding :confused: or you can check online tutorials :slight_smile:

Oh no, i know the coding, and i have the code, i just am confused how to implement it into the site with the html code thing

okay okay so, to begin with, you cannot add php code inside a .html file, you will need to make your site files in php form, in which you can add html stuff. For the log in system you want to create I would strongly recommend you to check this video out, it’s completely beginner-friendly and will help you get what you need step by step : https://www.youtube.com/watch?v=xb8aad4MRx8
Happy coding :smile:

Hi! Thank you so much! So how would i change my site format? Just change files to .php?

1 Like

Yep :slight_smile:

1 Like

Hello @hooman

I’m not too much late (Just 2 days :smile:)

There are two ways to create a login system.

  • By adding a pre-written code directly
  • Writing your own code

I can see you are adding a code and making it working. But, if you know programming, I highly recommend to create your own one. So, that would be easy to manage in the future.

This is the tutorial I started with.

Let’s think you created the login system. Then, you should have a PHP function to check whether the user is logged in or not. If use is not logged in, you can redirect them to login.php from index.php

Redirection code will look like:

if (!check_login()) {
    header('Location: /login.php');
    exit();
}
2 Likes

so do i enter that in the HTML block or? im so confused…

No first you have to follow the above tutorial (wikiHow) and understand it.