• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

passwort speichern und per cookie wiedererkennen

htmler123

Neues Mitglied
ich habe folgendes problem:
ich will eine Passwortabfrage einrichten wo der client eine Checkbox anklicken kann, wodurch dann ein cookie platziert wird
der user soll anhand des cookies wiedererkannt werden damit sein Passwort das er beim letzten besuch eigegeben hat wieder in das eingabefeld kopiert wird und er bloß noch Enter drücken muss

hier mal mein script:

Code:
[SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]<h2 [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]align[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]"center">[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]Kleine Passwortformalit[B][I]&auml[/I][/B];t[/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]</h2>[/COLOR][/SIZE][/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]<form [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]action[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]"index.php" [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]method[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]"post">[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]<table [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]align[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]"center"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]>[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]<tr>[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]<td>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]<b>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]Passwort:[/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]</b>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]</td>[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]<td>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]<input [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]type[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]"password" [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]name[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]"pass"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] /[/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]</td>[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]<td>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]<input [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]type[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]"submit" [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]value[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]"senden"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] /[/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]</td>[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]</tr>[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]<tr>[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]<td></td><td></td><td>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]<input [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]type[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]"checkbox" [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]name[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]"speichern"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] /[/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]>[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]<b>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]passwort speichern ??[/SIZE][SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]</b>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]</td>[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]</tr>[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]</table>[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000f0][SIZE=2][COLOR=#0000f0]</form>[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]<?php[/SIZE]
[SIZE=2]if (isset ($_POST['speichern'])) {[/SIZE]
 
[SIZE=2]setcookie("savepw", "yes" , time()+86400*30);[/SIZE]
 
[SIZE=2]}[/SIZE]
[SIZE=2]?>[/SIZE]
 
[SIZE=2]<?php if (isset ($_COOKIE["savepw"])  &&  $_COOKIE["savepw"] == "yes"){[/SIZE]
[SIZE=2]echo "cookie wurde erkannt";[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]?>[/SIZE]
 
Auf den ersten Blick sieht es korekt aus, nur was mich persönlich stört ist das du keine lücken machst evtl liegt es auch daran :D (formaction => form action)
 
Dafür brauchst du nicht extra einen neuen Thread aufmachen, aber gut!

Nutze nicht [html ] - Tags hier im Forum sondern immer [php ]- Tags (die HTML-Tags sind kaputt und highlighten keinen PHP-Code der im PHP-Forum sicher interessanter ist als der HTML-Code!)

Sensible Daten wie Passwörter gehören nicht in Cookies :!:

Schreibe mal ganz an den Anfang der Datei:

PHP:
<?php
echo '<pre>', print_r( $_COOKIE ), '</pre>';
?>

um zu schauen, welche Cookiedaten übermittelt wurden!

Wie bereits thuemmy im anderen Thread gepostet hat, wird ein Cookie erst nach dem Scriptende aktiv. Es ist also zuerst ein Refresh der Seite notwendig, damit folgende Bedingung:

PHP:
if (isset ($_COOKIE["savepw"])  &&  $_COOKIE["savepw"] == "yes"){
echo "cookie wurde erkannt";
}
ein true zurückliefert und der Text ausgegeben wird!
 
nö meinem script das auf der platte und auf dem server liegt war schon alles auseinander das hängt iwie mit dem forum zusammen oder auch mit mir ich weiß nicht aber der code war schon vorher auseinander geschrieben und es hat nicht gefuntzt :(
 
Code:
Array(    [Apache] => 87.176.242.51.1243955480923600    [__utmc] => 104144668    [__utma] => 104144668.1662201066.1243955828.1243955828.1243955828.1    [__utmb] => 104144668.2.10.1243955828    [__utmz] => 104144668.1243955829.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)    [LBC] => c91d5f6bd5581d50f9599c268e973cf1)1

das ist mal die ausgabe von der funktion die du mir genannt hast hab aber keine ahnung was sie bedeutet

und was den refresh betrifft danach hat das script den text immer noch nicht ausgegeben leider :(
 
also soll ich dann eine extra seite machen die cookie ausliest und den echo-text ausgibt...

und die datei soll ich dan wieder per include() einbinden?
 
machste einfach
PHP:
if(isset($_GET['read'])){
   if($_COOKIE['savepw'] == "yes"){
      echo "jau";
   }else{
      echo "neeee";
   }
}
aufrufen kannste es dann indem du hinter dienen dateinamen im browser ?read eingibst...
 
kann das auch mit dem Anbieter zusammenhängen denn ich habe einen kostenlosen webspace bei tripod.lycos der mich die ganze zeit mit werbung vollpumpt

kann es sein das der meine cookies ändert?

denn ich hab mal meine cookies gecheckt und da war nie eine mit dem inhalt yes dabei sonder nur kryptische zeichenfolgen
 
Zurück
Oben