I have no idea how you would edit a text file with lines that are either an email or a line that does not contain an email. So the only thing identify what you want is the @...
So my thought is to output a table inside a form with two columns, one for the email and another with a radio selector that allows me to append the email to the left of the radio button. Can anyone feel me on this?
Is there a better way to get this done? Maybe when they originally inputted have some sort of hidden id?
Not sure how you would do that with just the @ for a key... And no telling how many emails there will be.
alertmon_user.txt looks something like this
#fjkdslafjkdsla
#fjdlksajfdlksa
#jfdlksa
test@test.com
two@jfdslk.com
three@fjsld.com
and this script works great for separating the email addresses from the stuff I don't want.
<?php
$search = '@';
$lines = file('alertmon_user.txt');
foreach($lines as $line)
{
if(strpos($line, $search) !== false)
echo $line;
}
?>
So my output now looks like this
test@test.com two@jfdslk.com three@fjsld.com
Here's how I processed the form to get the email to the text file...
<?php
$txt = "alertmon_user.txt";
if (isset($_POST['field1'])) {
$fh = fopen($txt, 'a');
$txt = $_POST['field1'];
fwrite($fh,$txt . PHP_EOL);
fclose($fh);
}
?>
Any creative ideas on how I can edit 1 or all of the email addresses, no matter how many they are? Or do I need another approach?
I feel like I'm painting my way into a corner?
Thank you.