Jump to content

Recall Stored Data for login


TheJoey

Recommended Posts

Here is my code so far

<?php

$email = $_POST['email'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$age = $_POST['age'];
$address = $_POST['address'];
$city = $_POST['city'];

$fp = fopen("data.txt","a");

if(!$fp) {
    echo 'Error: Cannot open file.';
    exit;
}

fwrite($fp, $email."||".$fname."||".$lname."||".$age."||".$address."||".$city."\r\n");

fclose($fp);
?>

 

im having real trouble reclaiming that text for a login script.

Could anyone start me off.

Link to comment
Share on other sites

well i was thinking of going to make everyone [0] a username and [1] a password from my stored information. How would i go about doing so?

Array
(
    [0] => joe@joe
    [1] => joe
    [2] => joe
    [3] => 21
    [4] => as
    [5] => as

)

Array
(
    [0] => joe@joe
    [1] => joe
    [2] => joe
    [3] => 21
    [4] => as
    [5] => as

)

 

so [0] => joe@joe would be my username and

    [1] =>joe would be my password

Link to comment
Share on other sites

<?php
$userinfo = file("data.txt");

   echo '<table>';

foreach($userinfo as $key => $val) 
{
   $data[$key] = explode("||", $val);
}

for($k = 0; $k < sizeof($userinfo); $k++) 
{ 
   echo '<tr><td>Username:</td><td>'.$data[$k][0].'</td></tr>';
   echo '<tr><td>Password:</td><td>'.$data[$k][1].'</td></tr>';
   echo '<tr><td colspan=2> </td></tr>';
}

   echo '</table>';
?>

 

This is displaying it a little easier to explain i think.

Username: joe@joe

Password: joe

Username: joe@joe

Password: joe

 

Link to comment
Share on other sites

was thinking something like this for the form.

Having trouble using the code you gave me to proccess the login

echo '<table>
<tr><td>Username<br>
<form action="read3.php" method="post">
<input name="username" type="text"></td></tr>
<tr><td>Password<br>
<input name="password" type="password"></td></tr>
<tr><td><input value="Submit" type="submit"></td></tr>
<tr><td><a href="register/index.php">Register</a></td></tr>
</table>';

Link to comment
Share on other sites

was thinking something like this for the form.

Having trouble using the code you gave me to proccess the login

echo '<table>
<tr><td>Username<br>
<form action="read3.php" method="post">
<input name="username" type="text"></td></tr>
<tr><td>Password<br>
<input name="password" type="password"></td></tr>
<tr><td><input value="Submit" type="submit"></td></tr>
<tr><td><a href="register/index.php">Register</a></td></tr>
</table>';

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.