so how would this be done?
so far i have:
<?php
require 'db.php';
$info = $_POST["email"];
$ip = $_SERVER["REMOTE_ADDR"];
$query = mysqli_query($link,"INSERT INTO `email`(`email`,`ip`) VALUES ('{$info}', '{$ip}')");
?>
<html>
<form action="" method="POST">
<textarea rows="5" cols="80" id="in">
</textarea>
<input type="submit" name="insert" value="Insert">
</form>
The Values of the text area aka "in" will be something like 127.0.0.1:8080:hello@example.com
How would I use text splitting to split the ":" into the next insert value to do this?
Also: Bare in mind I want the IP:Port in the IP section, thanks! Thanks!
You can use explode()
for this
http://www.php.net/explode
$string = '127.0.0.1:8080:hello@example.com';
$arrray = explode(':',$string);
echo $array[0]; // prints 127.0.0.1
So IP will be -> $array[0]
Port will be -> $array[1]
Email adress -> $array[2]
Use explode():
$string = '127.0.0.1:8080:hello@example.com';
$ary = explode(':',$string);
var_dump($ary);
Demo: https://eval.in/84458
Try this:
$string = '127.0.0.1:8080:hello@example.com';
$arr = explode(':',$string);
$val="";
foreach ($arr as $a){
$val .= "'$a'"." ,";
}
$val=rtrim($val,",");
$sql = "insert into table(ip,name,email) value(".$val.")";
echo $sql;
OUTPUT:
insert into table(ip,name,email) value('127.0.0.1' ,'8080' ,'hello@example.com' )