Jump to content

freebsdntu

Members
  • Posts

    56
  • Joined

  • Last visited

    Never

Posts posted by freebsdntu

  1. Thank you for your reply,rajivgonsalves .I tried your method, but got this:

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent

    I remember I read somewhere that session_start() should always be the first statement,I don't know whether it is due to this reason.

    Also,does that mean I must include the file in every php file that I am gonna use the object?

  2. I have created a user class for user,in the class, there are profile attributes like names,email,etc and I also have get and set method for each of the attribute. Besides those, there are also user action methods like browseProfile,editProfile,etc

    When a user log in,I will instantiate a user object,the problem is how to remember the object so that other php files can also use it?I have tried something like this:$_SESSION['user'] = $user, where the $user is the object.But id did not work. Does anybody have any suggestion on how to do this?

    Thank you very much!

  3. Hi guys,

    I am building a system where there are 2 types of users,odinary user and super user,when they login,they will both have a control panel,but with different user actions based on their user type. So for the logged in page, should I write seperate pages for each type or should I just write one page, with conditional php?

    Thank you in advance!

  4. put in a hidden field in your form say

     

    <input type="hidden" name="submitform" value="Yes">

     

    and then check

     

    if (isset($_POST['submitform']) && $_POST['submitform'] == 'Yes') {
    .. your form processing code here
    }

    should the input tag be form tag,I guess?

    Thank you very much,rajivgonsalves. Now it works fine! :) Can you also give me some explanations on that?

  5. I wrote a php registration file which contains both the presetation - the form, and the logic to get the user input. The problem is when loading the page, the php logic will be executed even when user has not entered anything yet, how do I handle this problem?

    Previously I created two seperate files, register.html and register.php, where the form action would trigger register.php, and it worked fine.

    Any hints?Thank you very much! 

  6. Hi guys,I am trying to write a very simple photo album, like the one on msn space.

    I am planning to make use of both php and javascript, actually I would prefer to use more of js to handle client side operations.

    What I am trying to do now as a start is to get all the image urls of a album folder on the server. I tried to store all the image urls into an array in server side php, the question is how do I pass the array to client side so that my javascript code can access it?

     

    here is the php code I have written, just for reference.

    <?php
    class PhotoAlbum
    {
        var $albumUrl; /*the url of the album*/
        var $size; /*totl number of images in the folder*/    
    
        /*class constructor*/
        function PhotoAlbum($albumUrl)
        {
            $this -> albumUrl = $albumUrl;
            $this -> size = 0;
        }
    
        /*function to get total number of photos in an album*/
        function getSize()
        {
            $this -> getImageUrls();
            return $this -> size;
        }
    
        /*function to store the urls of each image into an array and returns the array*/
        function getImageUrls()
        {
            $imageUrls = array();
            if (!($dir_handle = opendir($this -> albumUrl)))
                echo "cannot open directory '$this -> albumUrl'";
            while ($file = readdir($dir_handle))
            {
                $size = $size + 1;
                array_push(imageUrls,$file);
            }
            $this -> size = $size;
            return $imageUrls; 
        }
    
    }
    ?>

     

    Also I would love to hear better approaches regarding the design?

  7. I am writing a script to display user profile and let the user edit his or her profile.

    Regarding the password field,since it is stored as md5 hash string in the database,so how can I get it back to normal string?

    Also would there be any security issues in doing the conversion? I would display the password as password input type,of course.

    Any hints?Thank you!

  8. function editProfile()
    {
        echo '<html><head></head><body><form><table>
                <tr><td><label for = "Fname"></label></td><td><input type = "text" id = "Fname" value = ""></td></tr>
                </table></form></body></html>'
    }

    I have a function to retrieve the Fname field from database,the problem is how am i set it as the default value for the input field

  9. I am writing a php code to retrieve user profile from database and display the data,also let the user to edit his or her profile.

    I use php to echo the form.For instance, for the username field.

    <input type = "text" id = "username" name = "username" value = "">

    What am i gonna write to the value = "" attribute?So that it loads with the profile?

    Thank you!

  10. I just did a google search,if I understand it correctly,it should be implying the start of a query string.

    Back to the main issue,if I do that,I would have to load the entire page,don't I?

    What if I only want to load the content portion,rather then the link portion which is the same for all the pages?

  11. Hi, the design is like this.

    In a webpage,I have a left side navigator occupying about 20% of the width,the remain 80% on the right becomes the content part.

    Say in the navigation bar,there are several links, and I would like to display corresponding contents on the right depending on which link the user presses. How do I achieve this? I have heard of the Iframe approach, but my concern is the compatibility with browsers,is there an alternative way to achieve it in php?

    Thank you very much!

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.