1

This could come in ANY form from sending a preformatted email with the click of a button, or just storing the data somehow. The goal implementation would be that the user never leaves the site so a mailto: is an extra step we would like to avoid unless we can send it instantly and not worry about having the email address be entered as the user's.

Ideally, the user just puts their name in, clicks send, and we can read it. I've never hosted a database before but if we need one is there a simple database we could use to implement this feature?

perryr
  • 89
  • 1
  • 5
  • I'm not sure I understand what you are trying to do. A database is a tool that can store data. So if you want ti save what you collect, you will need a database of some sort. Even if that data is emailed to your email, your email provider store that email in a database. – FMaz008 Dec 10 '20 at 21:37
  • I guess I'm asking if there was a way to skip the database, that is what I'm looking for. Email was just an example of a tool that we'd be okay using as an alternative to storing the data – perryr Dec 10 '20 at 21:45
  • 1
    You can write a file on a hard disk. You still need some sort of server, however. – VLAZ Dec 10 '20 at 21:46
  • 1
    What about a form to email SaaS like formspark.io ? See if this answer helps https://stackoverflow.com/questions/8239782/how-to-create-an-email-form-that-can-send-email-using-html – sallf Dec 10 '20 at 21:57
  • One of the most basic form of data base would be a CVS file. Which is a database contained in a single file. Basically a table where every column is separated by a coma. – FMaz008 Dec 10 '20 at 23:58

1 Answers1

0

To my knowledge you could use PHP and write it to a file in an array. Here is an example. Let's say you have a button with the id "ClickBtn" and two input tags with the id "Password" and "Username". We want to store any info in "Password" and "Username" to an Array whenever you click the button "ClickBtn". Here is what our HTML code looks like:

<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <!-- Can Be Set To Your Favored Version Of JQuery -->
<script>
function SaveToFile(){
   var Username = document.getElementById("Username").value;
   var PWord = document.getElementById("Password").value;
   function GetFileCount(pword){
    $.ajax({async: false,
        type: 'GET',
        url: 'SaveToDatabase.php?v=' + pword + '&uname=' + Username,
        success: function(data) {
            console.log(data); // What To Do When The PHP Echos Back Data
        }
    });
}
}
</script>
<input id="Username" placeholder="Username"></input>
<input id="Password" placeholder="Password"></input>
<button onclick="">Save</button>
</html>

Now that we have a functioning script, we are going to need a PHP script that can save the data. We would probably write something like this (Using $_GET["v"] To Retrieve The Password And $_GET["uname"] To Get The Username):

<?php
    $path = __DIR__ . '/OurDataBase/MainArrayFile.txt';
    $pword = $_GET['v'];
    $uname = $_GET['uname'];
    if(file_exists($path)){
        $curarray = file_get_contents($path);
    } else {
        $curarray = array();
    }
    $curarray[$uname] = $pword;
    echo $curarray;
?>

And now all you have to do is change it up to your liking! Happy password logging!

PS: If I didn't understand then I am terribly sorry for wasting your time.