Ahoj už mam rozpracovaný registraci a login. Jméno souboru pro registraci je druhysoubor.php a jméno pro login je Registrace.php trosku se to motá ale budiž. Zápis do souboru funguje dokonce i jeho přečtení (myslím) ale když kliknu na stránku pro login vyskočí chyba: Notice: Undefined index: jmno in C:\xampp\htdocs\projekty\login\Registrace.php on line 35. A i když zadám správně heslo i jméno které jsem registroval a zadali se do text souboru tak mi je to nevezme. Ještě přiložím oba kódy a jestli by mi to tu někdo mohl zprovoznit.
KÓD pro registraci :
Registrace: <a align = "center" href = "Registrace.php">Login</a>
<form action = "druhysoubor.php" method="GET">
<input type="text" name="jmn">
<input type="text" name="hesl">
<input type="submit" name="zapis" value="Registrace">
</form>
<?php
if (isset($_GET["hesl"])){
$heslak = $_GET["hesl"]; }
if (isset($_GET["jmn"])) {
$string = $_GET["jmn"];
if (isset($_GET["zapis"])){
$misto = "./file.txt";
$nactenySoubor = fopen($misto, "w");
fwrite($nactenySoubor, "$string\n" );
fwrite($nactenySoubor, "$heslak\n" );
fclose($nactenySoubor);
}
}
?>
KÓD pro Login :
Login: <a align = "center" href = "druhysoubor.php">Registrace</a>
<form action = "Registrace.php" method="GET">
<input type="text" name="jmno">
<input type="text" name="hesla">
<input type="submit" name="prih" value="Přihlásit">
</form>
<?php
$misto = "./file.txt";
$nactenySoubor = fopen("./file.txt", "r");
$txt=fgets($nactenySoubor);
fclose($nactenySoubor);
$pole = explode(",",$txt);
if(($pole[0] == $_GET["jmno"]) && ($pole[1] == $_GET["hesla"])){ echo "Byli jste úspěšně přihlášeni."; }else{ echo "Zadejte heslo. Pokud se tak již stalo a nebyli jste úspěšně přihlášeni zadejte jméno a heslo znovu. ";}
Fórum › PHP
Registrace/login php s ulozenim do file.txt

Resil bych to takto:
$form = array(
'jmno' => "",
'hesla' => ""
);
foreach($form as $key=>$value)
{
$form[$key] = isset($_GET[$key]) ? $_GET[$key] : $value;
}
// --- Zapis ---
Example #1 fputcsv() example
<?php
$list = array (
array('aaa', 'bbb', 'ccc', 'dddd'),
array('123', '456', '789'),
array('"aaa"', '"bbb"')
);
$fp = fopen('file.csv', 'w');
foreach ($list as $fields) {
fputcsv($fp, $fields);
}
fclose($fp);
?>
// --- cteni ---
Example #1 Read and print the entire contents of a CSV file
<?php
$row = 1;
if (($handle = fopen("test.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "<br />\n";
}
}
fclose($handle);
}
?>
//jen bych tam
// pridal $list = array();
// zmenil for ($c=0... na $list[] = $data
// a na konci dal var_dump($list);
Tam je to totiz dost nestastne udelane, ze to neni reverzni. Prepsal jsem to jeste cele, radeji.
<?php
$file = "file.csv";
$list = array(
array('John A. Smith' , 'San Francisco', 19),
array('Bob I. Uncle' , 'Los Angele' , '789'),
array('"Joan K. Jones"', '"New York"')
);
$fp = fopen($file, 'w');
foreach ($list as $row) {
fputcsv($fp, $row);
}
fclose($fp);
echo '<pre>'; var_dump($list);
?>
<?php
$file = "file.csv";
$list = array();
if (($fp = fopen($file, "r")) !== false) {
while (($row = fgetcsv($fp, 1000, ",")) !== false) {
$list[] = $row;
}
fclose($fp);
}
echo '<pre>'; var_dump($list);
?>

Přidej příspěvek
Toto téma je starší jak čtvrt roku – přidej svůj příspěvek jen tehdy, máš-li k tématu opravdu co říct!
Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku
×Vložení zdrojáku
×Vložení obrázku
×Vložení videa
Aktuálně jsou podporována videa ze serverů YouTube, Vimeo a Dailymotion.
×






























































Uživatelé prohlížející si toto vlákno
Uživatelé on-line: 0 registrovaných, 76 hostů
Podobná vlákna
Registrace/login php s ulozenim do .txt — založil Predict
Create TxT file — založil Kenvelo
Zobrazenie dat z txt file do listview — založil duro1
SMS registrace v PHP — založil ppeter
Problém s registrace.php — založil jAkErCZ
Moderátoři diskuze