php - Inserting photo and get photo -


hi want make possible when user sign default photo upload in db right i'm upload don't know if correct or not here code:

 <?php  require_once 'includes/header.php';    $profile_pic = basename('files/img/default.jpg');   if (input::exists()) {  //also here check our token see if input if (token::check(input::get('token'))) { //new instance $validate = new validate(); //now here check our validation check method //fist of check if post then: $validation = $validate->check($_post,array( //contain rulles want  //first of in username set in our db 'username'  => array(   //its required    'required' => true,    //minimum character 2    'min'      => 2,    //maximum character 20    'max'      => 20,    //and want 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 match 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            regsiteration please log in</span> ');     redirect::to('index.php');    } catch (exception $e) {     die($e->getmessage());   }    }else {   //if error   foreach ($validation->errors() $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 declare use method input class username when see error dont miss value , 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 token value--> <input type="hidden" name="token" value="<?php echo token::generate();?>"> <br> <span class='fieldname'>&nbsp;</span> <input type="submit" value="signup" class='info-signup'> </form> <br> 

now said see in db default.jpg exists when user sign first don't know if photo or name of photo , second cant show photo in user profile page

you never want save image's actual data database. being said, code stores path name database how should have been done.

double check if using correct path.

use

<img src="<?php echo $your_avatar_url; ?> /> 

to output image.

look how have user upload image here http://www.w3schools.com/php/php_file_upload.asp


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -