Jump to content

jimfog

Members
  • Posts

    1,803
  • Joined

  • Last visited

Posts posted by jimfog

  1. I am talking about the color of the placeholder text and NOT of the text being typed. Currently I have this CSS:

    ::-webkit-input-placeholder { color:#666666;font-size: 12px;}input[type=text]{width: 297px;padding: 5px;outline: none;border: 1px solid #999999;border-radius: 3px;}

    Although I think the second declaration is not needed for the topic I included any way. As you see, current placeholder text color is #666666 and I want this, on focus to get a different value.

  2. Οκ...but what I am trying to achieve is something different.It is simple though. I want, when the user focus on the search field the color of the placeholder text to change-like facebook searchfield.So far, I have styled the placeholder text color with css(::-webkit-input-placeholder).

  3. ???? why! the value of the search query can be retrieved when the user clicks the button, or the presses the enter key, by using onsubmit on the form element, why retrieve the value on every keypress the user makes. you usually test to see if the user has entered a value other than default value or empty value with code similar to
    function searchfield_focus(elem)	{	  if(elem.value == elem.defaultValue)		  {		elem.value="";		}	} function searchfield_blur(elem)	{	  if(elem.value == "")		  {		elem.value= elem.defaultValue;		}	}

    if the user enters a value other than the default, or empty it will show that value instead, if the user empties the value it will return back to default.

    To be more precise, I am going to use an example to demonstrate how my search box I want to behave-and this example is facebook and the search field that appear on top of the page and in it you will find the value "search for people...etc". So far I have managed, when the user focus, to make the color of the letters change.and now I am in the step where the user has to type a search query. Here are the functions that demonstrate what I have achieved so far:
    function searchfield_focus(obj){obj.style.color=""obj.style.fontStyle=""if (obj.value=="search..."){obj.style.color="#999999"	    obj.value="search..."}     }function searchfield_blur(obj){   obj.style.color=""obj.style.fontStyle=""if (obj.value=="search..."){obj.style.color="#666666"	    obj.value="search..."} }

    I hope a was clear.

  4. I have an input box-it is a search field to be more precise. I have used the onfocus event such that when the user clicks inside the box, it gets a value. Now I want, upon the user beginning to type, the value inside the box to become an empty string, here is somecode to get an idea what I am talking about: The HTML:

    <form action="results.php" method="post"> 		    <input name="search" type="text" style="color:#666666;"				   onkeypress="searchfield_keypres(this)" onfocus="searchfield_focus(this)" onblur="searchfield_blur(this)" size="41" value="find..." />		   <button id="searchbutton" type="button">search</button>			    </form>

    Nothing is wrong so far.The problem begins when using the onkepress event.I can only type ONE letter. The above does not surprise me though. How am I going to fix it? In short:1.The input/search box has a value.2. ON keypress I want this value substituted by the search query of the user Here is the keypress js function:

    function searchfield_keypres(obj){    obj.value=""   }

    In other words the obj.value above must reflect the search query of the user.

    code

    So, concluding , a check MUST be done if the form was submittedWhich means code like the one below is wrong-from a logic point of view:

    try{ if (!filled_out($_POST))	  {    throw new Exception(Go back -You did not filled the form');	   } 	    else { 	  	 // they have just tried logging inif(login($username, $passwd))// function to check the user in the db{$_SESSION['valid_user']=$username;   //code producing HTML here    

    And another question.Do you think that it would better that form action should be in the same page the form is in or in a different one.

    code

    It depends what values you want to check for, check the manual to see the values that PHP considers to be empty.
    Yes, I will see the manual-anyway the form is a form about username and password, nothing else to it, just these 2 fields.But since we are talking about strings empty() will be OK-I checked the manual.
    I disagree. Often times forms submit to themselves, typically for providing validation feedback.
    I did not quite understand that...
    It is often practice to check to see if the form was submitted first, as the first point in the control logic for rendering the page. If the form was submitted, you can test for that and act accordingly, if it wasn't you can skip a whole bunch of form processing logic and just show the user the form.
    I have in one page the form(HTML) and in another the logic(POST)-is in that enough? I mean that in order for the second page to be parsed, form SUBMISSION must have taken place... I believe the last sentence where you mention..."skip processing logic" mainly applies in cases where the page the form is, is also the rest of the logic: for example, in index.php is the form and the form action is also at index.php. In my case form action is a different page(index2.php for example).

    code

    So, you are saying that in case of a web form empty() will do the job-and that is that, In addition to the above I do not see the need to check if the form is submitted,you just go straight checking if the fields are empty or not and that is where it ends.

    code

    So in essence, 2 checks must be done: One that the form was submitted(using isset...)and second that the form fields were not empty. Of course the first check must precede the second-I think. And another thing... You said isset checks if variables are not null. How come the fields of a form(html name attribute)are considered variables? I miss something here... Yes I miss, what I miss is the fact that the fields of the form, become part of the POST array-arrays are variables too of course

    code

    This line: if (isset($_POST['username'])) Only checks if the form contains a "username" field. It does not check if that field has a value or not, only if the form contains a field by that name that was submitted. The isset function checks if a variable is set, so that if statement is true if $_POST['username'] is set. It will be set if the form has a field with that name regardless of whether the user filled it out.
    So you are disagreeing with what has been said before-that isset(POST[username]) checks if the form fields have been filled?

    code

    So they are doing the same thing-in other words.The difference being that the that the code in post 1 checks only the username while in post 3 checks all of the POST values. I am going to put it this way. What is better and why. using code of the kind:

    if (isset username && password)

    or making an iteration of the array as the function filled_out above? I can only thing that the iteration might be more practical when we are dealing with many form fields.

    code

    If the code above checks if the form fields have been filled then what exactly the code below does?

        function filled_out($post){  // test that each variable has a value  foreach ($post as $key => $value) {	 if ((!isset($key)) || ($value == '')) {	    return false;	 }  }  return true;}

    Does the above code does the same thing with a different way?

    code

    Does the code below checks if the user has filled in the fields of a form?

    if (isset($_POST['username']))

    No reason to put code related to the password field of the form-I think I made my point.

  5. So, as I have understood so far:Session cookie to "transfer" data from page to page and ordinary cookie to deploy the persistent connection mechanism.

  6. use a regular cookie, like birbal and JSG have been trying to explain to you
    Οκ, the truth is that I got "lost" in this topic as to what I have to do. Regular cookies is the way to go-after all.
  7. Although I opened topic somewhere else, I wanted to open a separate topic about the question I am going to make. In persistent logins, the cookie holds also the username, does this act ALSO as the session ID? thanks.

  8. Ok, all in all, to implement the "remember me" option do I need both setcookie and session_parameters functions? And the username hash will go to setcookie.

  9. setcookie() is not responsible for session cookie. session_set_cookie_params() is the options for handling session cookie. when you use session , session cookie handle automaticly with the help of the parameter you set. so session_set_cookie_params() should have use before you use session and before you use session_start()
    Then if setcookie() is not used for the session, what is it used for? Is it maybe the setcookie sends ONLY the cookie?Setcookie has the expire property and session_set_cookie_parameters has the lifetime property. Are these properties the same? Difficult to understand it from what the php.net manual says. You say also that "value" will hold the hash of the username-yes, but the "value " property is found ONLY setcookie() and NOT in session_set_cookie-params.
  10. You need to call that function before you call session_start on every page, if you've already started the session on another page without changing the cookie parameters I don't think it will have any effect to try and do it later..
    Is in it enough to use setcookie() at the first page the user visits(usually the home page) and then subsequently using just session start to the rest ofthe pages of the site? Using setcookie more than once is like sending multiple cookies to the browser-is it OK to do that?
    It is done by setting another cookie using setcookie() where yyou can set the lifespan of your cookie. that cookie will hold hashed key of mixed data like username
    Regarding the above statement. How am I going to use setcookie to hold the username, in the php manual it mentions things, like name,value,time span etc...but where exactly does username "goes"
  11. I am talking about the cookie where the preferences of the user are "remembered"-the cookie which is "responsible" for when the user visits the site and he is automatically logined(if of course has checked previously the "remember me " option.) I think this is a session cookie. Suppose the user does not want to logout. Usually, how long is set the duration of such a cookie.Putting it also another way, for how much time, the user can "wait" that when re-visiting the site he would be auto login?

  12. After how much time I should make the cookie expire? What is the rule of thumb for this, if any? I am using setcookie to accomplish this.Using fiddler I saw that w3scools forum keeps the cookies for about to 5-6 days.

  13. It is more clear now...as to why window.print inside document ready does not work. In other words-and correct me if I am wrong-document ready deals many with elements that their state changes after an event,(upon clicking for example). probably, the above explanation might sound strange but this is how I perceived the issue-more or less.

×
×
  • Create New...