Im creating a social network site and i was able to create a user folder each time a new user signs up but my problem is copying a default image from a folder to that user folder how can i do that? I've searched the web on solutions like using Copy function in php but itsn't working
You can check my code and i would be glad if anyone could help:

<?php

$link= mysqli_connect("localhost","root","","new1");

if($link === false)
{
    die("ERROR: Could not connect. " . mysqli_connect_error());
}

$firstname = $_POST["firstname"];

$lastname = $_POST["lastname"];

$username= $_POST["username"];

$email = $_POST["Email"];

$password= $_POST["Password"];

$country= $_POST["Country"];

$gender= $_POST["Gender"];

$birthday= $_POST["birthday"];

$profilepicture= "default.gif";

$sql = "INSERT INTO 360tery (firstname, lastname, username,Email,Password,Country,Gender,birthday,Profilepicture) VALUES ('$firstname','$lastname','$username','$email','$password','$country','$gender','$birthday','$profilepicture')";

$result = mysqli_query($link, $sql);

if ($result)
{
    session_start();
    $_SESSION['email']= $email; 
    echo "<script type='text/javascript'>alert('Successfully Registerd!'); window.location.href='../html/updatedtimeline.html';</script>";
    mkdir("../html/users/".$username,0777);

    $defaultimagepath='../photos/default.gif'; //This is the path to my default image
    $userfilepath="../html/users/".$username."/"; //the path to the users file i want to copy image to 
    copy($defaultimagepath,$userfilepath); //copy function

}else{
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}

?>

So, the question is whether this user folder is a system directory, or something in the database? These are very different things. If a system directory for the user, then select the image from MySQL into PHP, and then simply write it as a file to the appropriate user directory.

Just remember the KISS (Keep It Short and Simple) for your code. Yours is too complex for such a simple operation. Minimize! Minimize! Minimize! :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.