Jump to content

jimfog

Members
  • Posts

    1,803
  • Joined

  • Last visited

Posts posted by jimfog

  1. I am trying to append text to an input element but I cannot, here is the code: HTML:

    <div id="form">	    <input size="40" placeholder="Address" type="text" name="Address"><br>	    <input size="40" placeholder="Phone" type="text" name="Phone"><br>	    <input size="40" placeholder="Service" type="text" name="Service">	    <input display="block" size="3" placeholder="Price" type="text" name="Price">				 <div id="addsrvice"><img align="center" src="Images/add_service.png"></div>	  </div>

    and the js code:

    $("#addsrvice").live('click',function(){   $(":input").last().append("<strong>test</strong>");})

    The goal is to add an input element address the service input field.The above js code even if it was correct would not do that-I am only using it for testing.

  2. it is not possible if you are using session based login system. when user is logged in you are basicaly giving the a authenticate session which is not possible without starting the session.
    yes, you are right about that. I meant something else:When the user goes to a page other than the home page, despite he might have a cookie(which mean he is "logged in"-in the meaning that he does not need to enter pass/username) the session code is located in the home page only(assignment in a session array), since no session assignment takes place in the page other than home, so session is started...the previous described scheme, is wrong of course. Session array assignment must be done in every page since the visitor might go there directly.
    pseudocode
     if(!isset($_SESSION['valid_user']))		{		 //check the remember me token		 //if it is true update the token,make user login,give them session,redirect to destination page		 //if false show up the login form		output_login_form();  		exit;		} 

    Here is my pseudocode...I do not know if it's right one though:
    if(!isset($_COOKIE['cookiename']))    {    output_login_form();    exit;    }    elseif((isset($_COOKIE['cookiename']))&& (!isset($_SESSION['valid_user'])))//this is what I was describing above{//check username against db//if correct, update cookie and start session}

    What do you think about the pseudocode above?

  3. It's fine to use sprites even if the images are static, sprites save the overhead involved in HTML requests because you have to make fewer requests to get the images if they are combined in the same file. I use sprites that have 20 or so different images in them for various buttons and states, like this one: tool-sprites.gif
    Seing this image now, I am going to be more specific about where I want to use the arrows-it is for a calendar, as such the arrows need to be there all the time-when changing the days for example. The above example lies behind my question. What do you think?
  4. I intend using image sprites, but the thing I do not know if it is recommended for image depiction scenarios. Let me explain: I want two images(the images of arrows) to appear simultaneously in the page.Is a sprite to way to in such a case? I think yes, I am not sure though. Somehow I think that css sprites is best for hover elements-when we need the part of the image sprite one at a time.

  5. No session, does not work, because the user might be logged in but the session not started. This happens when the returning visitor goes to a page other than home-below is the code I used:

    if(!isset($_SESSION['valid_user']))	{	output_login_form();  	exit;	}

    I will just for the existence of cookie or not and act accordingly.

  6. checking session empty or not will work but it has limitation (eg you have to store something in session for both guest and registered member. it wont work).
    I did not got quite got that. If someone comes and is logged out(a registered member) I will initiate session at that point plus I will issue the cookie.If guest comes, no session initiation at all- unless you are trying to say something else.
    but it is better to have a dedicated authenticated variable (boolean field) to indicate user is logged in or not. like $_SESSION['authenticated']=true;. some people check the existance of user id which was issued after successfull log in.
    I understood that. So besides cookie and session initiation, you mean that I have to set a variable also that will serve asan indication if user is logged in or not.
  7. you will check the persitant cookie only if user is not logged in.
    How am i going to check that?By checking if session array is empty? Yes..this is the way to go I think, checking the session array. If you have something to suggest-about how I check that the user is loggined-, I am listening.
  8. I have set a mechanism such that when a returning visitor comes to the site he gets a new cookie and the old one is invalidated.Nothing strange here-it works OK. Apart from the above when a visitor comes to the site-a new visitor-and goes not to the home page but in another one,there is function there that also checks for cookie, and if present show member relative content-in which case a brand new cookie is assigned-, if not present show the login form. And here is the problem: If a returning visitor goes to the home page and then to the 2nd page mentioned above, a new cookie will be issued twice-which is redundant of course. What can I do to avoid the above redundant code-"I shortcut" I mean. Checking for a cookie is needed in every page of the site for that case where the user might go to a page other than the home directly. I am thinking that maybe the solution is that I invalidate the cookie only when the user "lands" only on the home page, What do you think?

  9. No, the hash part of the URL's relation to the ID has been standard for a decade at least.
    Well, I am surprised to hear that. Then what is the point in using name attributes in the first place?I am talking about the period before HTML5 comes and renders it obsolete.
  10. Despite I know what a return keyword does am still confused regarding the practical applications of it. I reached a point in my code though that I might have to use and as such I would like to ask if my logic is correct. I have made a function that checks the existence of a cookie in a user's PC-no need to post all the code here.So the pseudo code would go like this:if(checkcookie==true){do this}else{...}Am I right to assume that the checkcookie function must a have a return keyword somewhere in it-specifically when the cookie has been checked againsta the Db-or else the above code will not work?

  11. I have set up a persistent login mechanism which works Ok-till now. The problem appears when the user attempts to go the member section directly(by typing the URL in the web address field), by bypassing the home page. In that case session will not work, I get the usual undefined index message-meaning no value was passed to the session array. As it is done in the home page of the the site. This leads me to the following conclusion-and tell me if I am right: I need to check in every page that a cookie exists in the user's PC and if positive assign a value to the session array. Now the only thing I am doing is just calling session_start at every page except the home page where the code is more, setcookie, redirection etc.

  12. There's no name attribute for the <a> element. The #hash part of the URL targets any element that has an ID matching the #hash value.
    So you are saying this is the method to follow to achieve what i want.
  13. Ok then, lastly everything comes doe to this question: Do you think I should use multi-platform functionality?You might say now that this depends on the app.Mine, is a scheduling application, what would you recommend for such an application?

  14. I want to make a link that besides going to a specific page, it must also go to a specific point in that page. How can I do that? In both cases it will be an href attribute, but how am I going to combine these 2 together?

  15. you can do that with myisam. but myisam has no foreign key facility. foreign key helps to keep integrated the data between tables. means if parent table data got delete it will automatically handle the data in child table.
    So for example, if a customer is deleted from the corresponding table, then his appointment will be auto deleted from the appointments table.Am I saying it correctly?
    also myisam used table level locking when it writes where as innodb uses row level locking. table level locking means it locks the whole table (innodb locks only the row) when it writes to database. though it happens on fraction of seconds but i high traffic site it can be be slower for concurrent request. as each request have to wait untill previous one finish his job. if your data is read heavy myisam will be fast. innodb is slower than myisam but as it is uses row level locking it is effective on write heavy tables. another important distinction is myisam can use full text indexing where innodb cant. in case you have to use full text indexing myisam is only choice. most of the case you will use innodb. use mysql where you have the strong reason to do so.
    Ok, so you are saying that depending the nature of the application-innoDB or MyISAM is better. So, for a booking.scheduling application what type of dB would you propose?
  16. Suppose we have 2 tables. The one is customers and the other the appointments the customers book. In the second table I want(as you guess) the appointments the customers will book. Question: Since the 2 tables will share a username column, do you think it is better if I inno DB tables instead of MyISAM. Can I do my job with MyISAM?

  17. Is there a way that I can bypass the problem and the local IP be printed in the browser. I am not doing it for experimentation purposes-I am developing an application in whichthe IP of the client has to be inserted into a table.

  18. I am trying to get the client IP using the following code:

    $ip=$_SERVER['REMOTE_ADDR'];echo "<b>IP Address= $ip</b>";

    The only the gets printed to the browser though is this:IP Address=::1 I am developing locally and as such the IP is 127.0.0.1-I believe this is that should beprinted in the browser.

  19. On logout besides deleting the cookie on the user's browserdo you think is necessary I should also delete username/token combo in the database. Probably yes...what is the reason for keeping them, but I just wanted to hear your opinion P.S I am storing the cookie token in a separate table along with the username.

×
×
  • Create New...