I have a site with an account, set up to phpmyadmin database.
I would like to be able to have the user upload an image associated with their account.
I am not too sure how to do this. My guess would be to have a column in the database that somehow references the picture?
Could i please get some help with examples showing me ways i can do this, i would love to learn how so i can do this in the future and how a user can be linked up with their image.
$username = $mysqli->escape_string($username);
$sql = "SELECT COUNT(*) FROM users WHERE email = '$username'";
if ($result = $mysqli->query($sql))
{
$row = $result->fetch_array();
if ($row[0] == 1)
{
$sql = "SELECT password FROM users WHERE email = '$username'";
if ($result = $mysqli->query($sql))
{
$row = $result->fetch_object();
$hash = $row->password;
if (crypt($password, $hash) == $hash)
{
echo 'Your login credentials were successfully verified.';
session_start();
$_SESSION['username'] = $username;
$queryLogin = "SELECT * FROM users WHERE email = '{$_SESSION["username"]}' ";
$myResult = $mysqli->query($queryLogin);
$myRow = $myResult->fetch_array();
$fname = $row["firstName"];
echo "<input type=\"text\" name=\"xyz\" value='<?php echo $fname; ?>' >";
}
else
{
echo 'You entered an incorrect password.';
}
}
if (empty($_POST['password']))
{
echo 'ERROR: Please enter a valid password';
$inputError = true;
}
else
{
$password = $mysqli->escape_string($_POST['password']);
}
if (empty($_POST['password2']))
{
echo 'ERROR: Passwords must match!!!';
$inputError = true;
}
else if ($_POST['password'] == $_POST['password2'])
{
$salt = crypt($password);
}
else
{
echo 'ERROR: Passwords must match!!!';
$inputError = true;
}
if($inputError != true)
{
$sqlInsertQuery = "INSERT INTO users (address, email, firstName, lastName, password)
VALUES ('$address', '$email', '$fName', '$lName', '$salt')";
$id = $mysqli->insert_id;
$sql2 = "INSERT INTO usersPhone (ID, homePhone) VALUES ($id, '$phone')";