Jump to content
WIK

[PHP / MYSQL] select valoare din baza de date.

Recommended Posts

Posted

am o coloana din baza de date cu formatul 

ip/ora:minut:secunda/data

0.0.0.0 03:30:59 06/02/2021

 

acum ce metoda as putea sa abordez in php intr-asa fel incat  sa pot verifica doar IP-ul cu alt ip ex: 

 

<?php
$ip = $_SERVER['REMOTE_ADDR'];
$output = "IP DIN BAZA DE DATE";
	if($ip == $output){
		echo "acest ip corespunde cu cel din baza de date";
	}else{
		echo "acest ip nu corespunde cu cel din baza de date";
	}

 

  • Moderators
Posted

 

<?php
$ipdb = "0.0.0.0 03:30:59 06/02/2021"; //aici preiei din baza de date
preg_match('/(.*) (.*) (.*)/', $ipdb, $matches);
echo $matches[1]; //IP
echo $matches[2]; //ora
echo $matches[3]; //data

$ip = $_SERVER['REMOTE_ADDR'];
if($ip == $matches[1]){
	echo "acest ip corespunde cu cel din baza de date";
}else{
	echo "acest ip nu corespunde cu cel din baza de date";
}

 

  • Like 1
  • Thanks 1
  • Upvote 3

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...