Привет, я хочу, чтобы это было возможно, когда пользователь зарегистрировал загрузку фотографий по умолчанию в моей БД прямо сейчас, я загружаю его, но я не знаю, правильно ли он его код:Вставить фотографию и получить фото
<?php
require_once 'includes/header.php';
$profile_pic = basename('files/img/default.jpg');
if (Input::exists()) {
//also here we check our token to see if input
if (Token::check(Input::get('token'))) {
//new instance
$validate = new Validate();
//now here we check our validation with check method
//fist of all we check if its POST then:
$validation = $validate->check($_POST,array(
//contain all rulles we want
//first of all in username as we set in our DB
'username' => array(
//its required
'required' => true,
//minimum character 2
'min' => 2,
//maximum character 20
'max' => 20,
//and we want it unique on users table
'unique' => 'users'
),
'name' => array(
'required' => true,
//minimum character 2
'min' => 2,
//maximum character 20
'max' => 50,
),
'email' => array(
'required' => true,
//minimum character 2
'min' => 10,
//maximum character 20
'max' => 50,
),
'password' => array(
'required' => true,
//minimum character 2
'min' => 6,
),
'SecondPassword' => array(
'required' => true,
//check for be match with password1
'matches' => 'password'
),
));
//is passed
if($validation->passed()){
$user = new User();
$salt = Hash::salt(32);
try {
$user->create(array(
'username' => Input::get('username') ,
'name' => Input::get('name') ,
'email' => Input::get('email') ,
'password' => Hash::make(Input::get('password'),$salt) ,
'salt' => $salt,
'joined' => date('Y-m-d H:i:s') ,
'lastlogin' => date('Y-m-d H:i:s'),
'avatar' => $profile_pic
));
Session::flash('home','<span class="success-sign">Thank you for your
regsiteration Please log in</span> ');
Redirect::to('index.php');
} catch (Exception $e) {
die($e->getMessage());
}
}else {
//if error
foreach ($validation->errors() as $error) {
echo "<span class='error-sign'>$error</span><br>";
}
}
}
}
?>
<form action="" method="post" enctype="multipart/form-data">
<label for="username" class='field-name'>Username</label><br>
<!--here in value we declare it to use get method from Input class to get
username for when we see error we dont miss this value and also for name -->
<input type="text" name="username" id="username"
value="<?php echo Input::get('username');?>" autocomplete="off"
onBlur ='checkUser(this)' class='signup'>
<span id='info'></span>
<br>
<label for="name" class='field-name'>Your name</label><br>
<input type="text" name="name"
value="<?php echo Input::get('name');?>" id="name" class='signup' >
<br>
<label for="email" class='field-name'>Your Email</label><br>
<input type='email' name='email' id="email" value="<?php echo
Input::get('email'); ?>"
class='signup'><br>
<label for="password1" class='field-name'>Password</label><br>
<input type="password" name="password" id="password" class='signup'>
<br>
<label for="secondpassword" class='field-name-re'>Retype Password</label>
<br>
<input type="password" name="SecondPassword" id="SecondPassword"
class='signup'>
<br>
<!--this is for token value-->
<input type="hidden" name="token" value="<?php echo Token::generate();?>">
<br>
<span class='fieldname'> </span>
<input type="submit" value="SignUp" class='info-signup'>
</form>
<br>
сейчас, как я уже сказал, я вижу, что в моей БД default.jpg существует, когда пользователь регистрируется, но сначала я не знаю, если его фотография или просто имя фотографии, а вторая я не могу показать эту фотографию в профиле пользователя страница