Problem with browsers on my PHP code

C++, C#, Java, PHP, ect...
Post Reply
User avatar
Infinity
Posts: 45
Joined: Sun Oct 31, 2010 12:27 pm

Problem with browsers on my PHP code

Post by Infinity »

Hi,

I have a little bit problem. I'm doing a little game on PHP and I browsers don't help with. In one moment, on the game, there are some questions and you should type an answer (input type text), I pass the answer by html POST then I compare, to look if it's the right answer. But I have a problem, browser remember all that you have written on the "input type text" so... in that way, if someone is right one time, it will be always right...
Anyone one knows anything that I could do to improve this?
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Problem with browsers on my PHP code

Post by Jackolantern »

Can you post the code?
The indelible lord of tl;dr
Xaleph
Posts: 897
Joined: Mon Feb 07, 2011 2:55 am

Re: Problem with browsers on my PHP code

Post by Xaleph »

Add this to your input field: disabled="disabled"

It`s the only part on Microsoft they contributed to the WWW which was worth the effort and not making it on the final drafts for a long time. Although most browsers did adopt it from the beginning..
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Problem with browsers on my PHP code

Post by Jackolantern »

Xaleph wrote:It`s the only part on Microsoft they contributed to the WWW which was worth the effort
Errmm...httpXmlRequest object AKA the entire foundation of AJAX? ;)
The indelible lord of tl;dr
Xaleph
Posts: 897
Joined: Mon Feb 07, 2011 2:55 am

Re: Problem with browsers on my PHP code

Post by Xaleph »

Correct, however, that one was adopted by the W3 standards comittee from the start. The first draft of JS, I believe, already provided such an interface. It just took a while for others to find good use for it. And, if i`m not mistaken, it was built in their liveScript, not javascript (ecma1.0)
User avatar
Infinity
Posts: 45
Joined: Sun Oct 31, 2010 12:27 pm

Re: Problem with browsers on my PHP code

Post by Infinity »

With disabled="disabled" the text label became disabled and I can't type in there nothing.

The code of this it's only this following lines:

Code: Select all

<form method="POST" action="verification.php">
Answer: <input type="text" name="answer" size="50">
<br>
Any idea?
Xaleph
Posts: 897
Joined: Mon Feb 07, 2011 2:55 am

Re: Problem with browsers on my PHP code

Post by Xaleph »

Hmm yeah, my bad, sorry. I actually had to google for the solution but here it is:

autocomplete="off"

This is the attribute I was talking about, and it would seem it still is not adopted by W3. So, if you want W3 valid code ( no real use for "valid" code, if you know what you are doing) but you can randomize fieldnames. Something like name="email_<?=randomNumber();?>" and use the substring or explode on the _. Anyway, autocomplete="off" should work just fine, the only downside is it will trigger an error on the validator.
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Re: Problem with browsers on my PHP code

Post by Callan S. »

I'm not sure if I understand the problem, but if it's that previous values show up, you can put in

Code: Select all

value="";
to show a blank value. Or whatever value you want.
User avatar
Infinity
Posts: 45
Joined: Sun Oct 31, 2010 12:27 pm

Re: Problem with browsers on my PHP code

Post by Infinity »

Xaleph wrote:autocomplete="off"
That have worked, thanks for all for your help. But now I have one last question, now I have a question that needs to be solved, with the same answer, I have two php files, one called question and one called verification, I pass the answer with a POST method. So now, If I want to make more different answers, how can I do, to pass an id of the question and the values written by the user if I have used the POST method? I mean, I can pass the answer, because it is on "input type= text", but..., How can I pass an ID for the question too?

P.D: Sorry for my bad English >__<'''
User avatar
Infinity
Posts: 45
Joined: Sun Oct 31, 2010 12:27 pm

Re: Problem with browsers on my PHP code

Post by Infinity »

Anyone can help me?
Post Reply

Return to “Coding”