Php get info user

PHP — How to get info from a newly created user

Im totally new to php but have been programming for around 5 years in C#. Im struggling to get my head around some of the basics in this. So i have an application that will take info from a user to create a new entry in my db for their new account. Once the account is created i then need to know their unique id. Should all of this be done in one php file? Or should i create another php file to grab the id? If i take the second approach how do i know what the email was they used in the first php file? In C# i get you can create references, and reference other variables but how do you do this in PHP? In my understanding if i use the include in any file it will execute all the code in that file? Thanks John Here is the PHP

query($sql) === TRUE) < echo "Welcome " . $firstName . " You are now an Rcader!"; >else < //echo "Error: " . $sql . "
" . $conn->error; $error = $conn->error; echo $error; >

You’ll really need to post specific code to answer this, but I typically handle these types of things at the class level, so the object fetches an id automatically after saving to the DB.

Читайте также:  Javascript длина имени переменной

You need to read up on web sessions and how cookies are used to persist sessions. I’d also recommend looking at a few PHP frameworks to see how some modern web applications are structured. This is not really a great question as is for SO. Good luck!

When you do your database insert, you can get the last insert id — then if needed, run another select statement.

Thanks everyone, i know its not a very good question and that is because i dont understand enough to know what im on about haha. As for the php this is what im currently using. ok im trying to find where to input the code.

Источник

PHP get user information

I made a website with a login script. Now there is some guy that makes false logins all the time. For example usernames like ‘lfdjgh’ and email addresses like jkgfhkjghf@dkhfkgh.com. I want to find out where this person is located etc. Is there a way to find some detailed information about that user? Computer-name, Ip address, location, etc? Thanks

Probably not a real person, but a spambot. Adding something like a captcha at your registration page might help filter those out.

8 Answers 8

I agree with that the other answers have said, you can use the values passed with $_SERVER to help avoid this.

Along with adding a CAPTCHA to your page, you can also add the IP address to your database, grabbed with $_SERVER[‘REMOTE_ADDR’] and compare known spam IP’s to new registrations, and check if its a known spammer. Its what I do, and I don’t have much spam at all (:

You can get the user’s IP using the $_SERVER variables, and store it when they submit the form. Then you could use a service to geographically locate the computer, like this one.

You can use certain values in $_SERVER to find out more about the attacker. In most cases $_SERVER[‘REMOTE_ADDR’] will contain the user’s IP address. Be aware though that there is no guarantee that this value is correct and there still might be some kind of proxy involved. The best way probably would be to use some kind of captcha to prevent bots from using your signup form. Because that’s most likely the reason.

you can use $_SERVER[‘REMOTE_ADDR’] to get the users IP-Adress (hopefully*) and then use a site like http://ip-lookup.net/ to get the broad location of taht address.

*there could be some kind of router/proxy/whatever in use together with other users (like in a students’ hostel, for example) where you would only get the ip-adress of that device, so you can’t identify a unique user.

i think the simplest way to track them is only to store the location and IP-address when some one make registration as well as when he/she login in your application from there location..its also safe and good practice for any admin; this entry will make you good tracked application for fake as well as real users too.

I think this facility provided by Google analytic also..they are provided all the details of the user hit on your applications with time/ipaddress/location etc.

But if the entry are just some kind of fake entry from the script only, then its batter to put captcha in your site..

You cannot (really) find out where the user is located (if it is what I suspect it is).

It’s probably some hacker (/ script kiddy) / spambot.

You can try to change your input field’s names to break the automated process of filling the formfields.

You can use the $_SERVER superglobal to find out the ip of the user.

You could suspend the ip address for some time also you could add a captcha to the form.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Getting The Client Information (Client’s IP Address,Operating System,Browser Name,Device Type) in PHP

marufhasan1/user_info

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Getting The Client Information (Client’s IP Address,Operating System,Browser Name,Device Type) in PHP

include('UserInfo.php'); //Or Use Require function require('UserInfo.php');

If you want to get the client IP Address, Use this Method, This Method will return Client IP Address

require('user_info.php'); echo UserInfo::get_ip()

If you want to get the client Operating System Name, Use this Method, This Method will return Client Operating System

require('user_info.php'); echo UserInfo::get_os();

If you want to get the client’s Browser Name, Use this Method, This Method will return Client’s Browser Name

require('user_info.php'); echo UserInfo::get_browser();

If you want to get the client’s Device Type Then Use this Method, This Method will return Client’s Device Type Name Such as Mobile,Tablet,Computer

require('user_info.php'); echo UserInfo::get_device();

About

Getting The Client Information (Client’s IP Address,Operating System,Browser Name,Device Type) in PHP

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

PHP class to get information about the site visitor (IP, reverse DNS, referer, OS, etc. )

olegkoval/php-user_info

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

PHP class to get information about the website visitor (IP, reverse DNS, referer, OS, etc. )

Use Composer to install the library:

composer require olegkoval/php-user-info 
  1. Call methods to get info about the website visitor:
  • $UserInfo->getIP() — get IP of visitor
  • $UserInfo->getReverseDNS() — get Reverse DNS of visitor
  • $UserInfo->getCurrentURL() — get current URL
  • $UserInfo->getRefererURL() — get Referer URL
  • $UserInfo->getDevice() — get Device type (PC/iPad/iPhone/etc. ) of visitor
  • $UserInfo->getOS() — get OS of visitor
  • $UserInfo->getBrowser() — get Browser type of visitor
  • $UserInfo->getLanguage() — get Browser Language of visitor
  • $UserInfo->getCountryCode() — get Country Code of visitor
  • $UserInfo->getCountryName() — get Country Name of visitor
  • $UserInfo->getRegionCode() — get Region Code of visitor
  • $UserInfo->getRegionName() — get Region Name of visitor
  • $UserInfo->getCity() — get City of visitor
  • $UserInfo->getZipcode() — get Zipcode of visitor
  • $UserInfo->getLatitude() — get Latitude of visitor
  • $UserInfo->getLongitude() — get Longitude of visitor
  • $UserInfo->isProxy() — check if connection was through proxy

Источник

Оцените статью