Help regarding hidden texts

3 replies
  • WEB DESIGN
  • |
Hello All

Is it possable for me to have some text on a page that is hidden unless you have logged in for example i have a web page that displays caravans for exchange with all the details for each van but i want to keep contact details hidden unless they have registered if you see what i mean to save having 2 pages 1 with all detals and 1 with restricted details ?
#hidden #texts
  • Profile picture of the author Thomas Frank
    Short answer... yes.

    Long answer... You'll need to know how to use PHP and MySQL to do it.

    If it's all going to be on one page, you can just have an if statement that only displays the content if the user is logged in. That involves authenticating user credentials that are entered into a form. When the form is submitted, the details are transferred from the $_POST array into instance variables, which are compared to details from the database. If the details are correct, you set another variable - you could do it like this (variables should start with dollar signs; this forum doesn't allow them):

    PHP Code:
    if ( enteredPassword == dbPassword
    {
     
    loggedIn  true;

    Then, you could structure your restricted text like this:

    PHP Code:
    if ( loggedIn true)
    {
       echo 
    "Restricted content goes here";

    This is a super simple example, but I hope it answers your question.
    {{ DiscussionBoard.errors[3469056].message }}
  • Profile picture of the author phpbbxpert
    Yes it is possible.
    It requires checking for a session, which you should have if the user logs in.

    I couldn't tell you what would need to be done without knowing what type of setup your website is running on.. Eg. WordPress, Joomla, etc....
    {{ DiscussionBoard.errors[3469070].message }}
  • Profile picture of the author jasonthewebmaster
    Banned
    Better to use wordpress or joomla for this. JOomla has this stuff built in.
    {{ DiscussionBoard.errors[3475072].message }}

Trending Topics