I want to insert multiple emails into the database using single text area.
This is my code :
PHP
error_reporting(E_ERROR | E_WARNING | E_PARSE);
$dbhost = "localhost";
$dbname = "emails_test";
$dbuser = "root";
$dbpass = "";
$conn = mysql_connect($dbhost,$dbuser,$dbpass);
if (!$conn) { die('Could not connect: ' . mysql_error()); }
mysql_select_db($dbname, $conn);
if(isset($_POST['submit'])) {
    //$email = nl2br($_POST['email']);
    $email = explode("\r\n", $_POST['email']);
    foreach($email as $emails) {
        $query = mysql_query("INSERT INTO emails (email) VALUES ('$emails')");
        if($query) { echo "Inserted into the database"; } else { echo"Fail, please try again"; }
    }
}
HTML
<body>
    <form name="form1" method="POST">
        <textarea rows="5" name="email" cols="50" ></textarea><br>
        <input type="submit" name="submit" value="submit">
    </form>
</body>
I want table to be like this : ![[Pic Table in MySQL]](../../images/3832089745.webp)
 
     
    
 
     
    