[TLDR] Big Newbie needs to make a array of files, holding data by user input from code below, that is viewable?[TLDR]
If the title is a misnomer sorry, but I am a very very green newbie trying to do a coding project with no experience in dealing with FTP or HTML or php.
How do i make a "array" of files , each element of the array being generated upon the entry of user data(first name, last name, email, comments) in main page of a website? These files in the array would hold the user's name, email, and comments, and be able to be removed.
I am using FileZilla Client to connect to my FTP server greenhousebra.comli.com/index.php .
On that page is the forum input for:
First Name [ text field] Last Name [text field ]
Email[text field ]
Message[Text box] [submit button]
When the text fields are entered, and submit is hit, it should send a email to the email address entered that I want to function like a ticket, and that works so far. But then I want another option to be able to go to another page and see the array of other people who entered their data as well.
the code for this was obtained from another stackexchange post, since i dont know any .php or HTML, and is posted below, it was held in my index.php file for greenhousebra.comli.com
The HTML code, in index.php file :
<!DOCTYPE html>
<head>
<title>Form submission</title>
</head>
<body>
<form action="mail_handler.php" method="post">
First Name: <input type="text" name="first_name"><br>
Last Name: <input type="text" name="last_name"><br>
Email: <input type="text" name="email"><br>
Message:<br><textarea rows="5" name="message" cols="30"></textarea><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
The mail_handler.php file
`
<?php
if(isset($_POST['submit'])){
$to = "email@example.com"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $first_name . " " . $last_name . " wrote the following:" . "
" . $_POST['message'];
$message2 = "Here is a copy of your message " . $first_name . "
" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
// You cannot use header and echo together. It's one or the other.
}
?>