This is not complete code
I would like to think that the likely-hood of two people creating an account from the same shared network ip addres is low to none but I am counting on the auto-increment function... the person is matched by the ID number assigned to him/her and then their IP address that they used to initially start the account creation process.
It is a two part process because I wanted them to simply enter their name, age and gender then "create account"
I suppose I could just do it all at once but part of the process is showing their information on a display and they can see their name on something and have the ability to decide if they like it or not
So this is the first page where they enter name/age/gender
<?php
global $name, $age, $gender ;
$name = $_POST['name'];
$age = $_POST['age'];
$gender = $_POST['gender'];
$name = mysql_real_escape_string($name);
$age = mysql_real_escape_int($age);
$gender = mysql_real_escape_string($gender);
?>
Then a .php file handles the posted data
<?php
header("Location: ");
error_reporting(E_ALL);
error_reporting(-1);
$servername = "localhost";
$username = "";
$password = "";
$dbname = "";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$i = $_SERVER['REMOTE_ADDR'];
$row_cnt = $conn->num_rows;
$c = $row_cnt;
$sql = "INSERT INTO NewAccount (Id,Ip,Name,Age,Gender)
VALUES ('$c++','$i', '{$_POST['name']}','{$_POST['age']}','{$_POST['gender']}')";
mysql_query($sql);
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
print_r($_POST);
$conn->close();
exit;
?>
Then I try to pull the data to fill out fields / decide graphical output based on information by echoing the values
This page is a mess, the code is everywhere even as a .php page
<?php
error_reporting(E_ALL);
error_reporting(-1);
$servername = "localhost";
$username = "cjdc";
$password = "";
$dbname = "";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
$row_cnt = $conn->num_rows;
$i = "SELECT Ip FROM NewAccount WHERE Id=$row_cnt";
$ipt = $_SERVER['REMOTE_ADDR'];
if ($ipt == $i) {
$name = "SELECT Name FROM NewAccounts WHERE Id=$row_cnt";
$age = "SELECT Age FROM NewAccounts WHERE Id=$row_cnt";
$gender = "SELECT Gender FROM NewAccounts WHERE Id=$row_cnt";
}
?>