1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
| <h2>Gérer les membres</h2>
<?php
if(isset($error)){
echo $error;
}
$attributes = array('id' => 'form_membre', 'enctype' => "multipart/form-data", 'method' => "POST");
echo form_open('admin/do_upload', $attributes);
?>
<label for="nom">Nom</label>
<input type="text" name="nom" id="nom"/>
<fieldset class="small">
<label for="logo_form">Logo</label>
<?php
$data = array('class' => 'input-form file',
'name' => 'userfile'
);
echo form_upload($data);
?>
</fieldset>
<fieldset class="small" style="margin-left: 20px;">
<label for="login">Login</label>
<input type="text" name="login" id="login"/>
</fieldset>
<fieldset class="small" style="margin-left: 20px;">
<label for="mail">Email</label>
<input type="text" name="mail" id="mail"/>
</fieldset>
<fieldset class="small" style="margin-left: 20px;">
<label for="site">Site</label>
<input type="text" name="site" id="site"/>
</fieldset>
<fieldset class="small">
<label for="fb">Facebook</label>
<input type="text" name="fb" id="fb" />
</fieldset>
<fieldset class="small" style="margin-left: 20px;">
<label for="twitter">Twitter</label>
<input type="text" name="twitter" id="twitter"/>
</fieldset>
<fieldset class="small" style="margin-left: 20px;">
<label for="google">Google</label>
<input type="text" name="google" id="google"/>
</fieldset>
<fieldset class="small" style="margin-left: 20px;">
<label for="youtube">Youtube</label>
<input type="text" name="youtube" id="youtube"/>
</fieldset>
<label for="description">Description</label>
<textarea name="description" id="description"></textarea>
<input type="hidden" name="posted" value="1"/>
<input type="submit" value="Ajouter" class="btn_form"/>
</form>
La méthode du controleur :
Code:
function do_upload() {
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if (!$this->upload->do_upload()) {
$error = array('error' => $this->upload->display_errors());
$this->layout->set_theme('admin');
$this->layout->view('admin/membres', $error);
} else {
$data = array('upload_data' => $this->upload->data());
$nom = $this->input->post('nom');
$login = $this->input->post('login');
$email = $this->input->post('mail');
$site = $this->input->post('site');
$fb = $this->input->post('fb');
$tw = $this->input->post('twitter');
$google = $this->input->post('google');
$youtube = $this->input->post('youtube');
$description = $this->input->post('description');
$filename = $data['file_name'];
$mdp_un = uniqid();
$mdp_deux = substr($mdp_un, 0, 8);
$mdp = sha1($mdp_deux);
$data['mdp'] = $mdp_deux;
$this->production->Ajouter_prod($nom, $login, $filename, $email, $site, $description, $mdp, $fb, $tw, $google, $youtube);
$this->layout->set_theme('admin');
$this->load->view('ajout_prod_success', $data);
}
} |
Partager