Jump to content

Search the Community

Showing results for tags 'databse'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 3 results

  1. Hello I need help concerning my code. I can't figure out how, if the user has logged in with the usertype as "admin". If so they should see a link if not then they are normal user. Here is an image of the database here is my code: $queryget = mysql_query("SELECT usertype FROM tbl_usernames") or die ("Query failed."); $row = mysql_fetch_assoc($queryget); if($_SESSION['username']= $row['usertype'] == "admin") { echo "<p><a href='create_user.php'>Create a new user</a></p>"; } else { echo "You are a normal user."; }
  2. I have an online form which when filled in and submitted converts into a pdf file and saves on database/server. I want to, as part of the process, attach the saved file on database and send as email.Currently am having ' failed to open stream: No such file or directory' while using phpmailer. I am not sure whether to use $_FILES function since I am not uploading a file. Any ideas or solution will help. Thanks in advance.
  3. Hi guys, Been fighting with this and can't get it to work. Basically, on submit, session is being updated but data is not being sent to the database. Here is my view_profile.php <?php if(!$this->session->userdata('id')) { redirect(base_url().'admin'); } ?> <section class="content-header"> <div class="content-header-left"> <h1>Edit Profile</h1> </div> </section> <section class="content" style="min-height:auto;margin-bottom: -30px;"> <div class="row"> <div class="col-md-12"> <?php if($this->session->flashdata('error')) { ?> <div class="callout callout-danger"> <p><?php echo $this->session->flashdata('error'); ?></p> </div> <?php } if($this->session->flashdata('success')) { ?> <div class="callout callout-success"> <p><?php echo $this->session->flashdata('success'); ?></p> </div> <?php } ?> </div> </div> </section> <section class="content"> <div class="row"> <div class="col-md-12"> <div class="nav-tabs-custom"> <ul class="nav nav-tabs"> <li class="active"><a href="#tab_1" data-toggle="tab">Update Information</a></li> <li><a href="#tab_2" data-toggle="tab">Update Photo</a></li> <li><a href="#tab_3" data-toggle="tab">Update Password</a></li> </ul> <div class="tab-content"> <div class="tab-pane active" id="tab_1"> <?php echo form_open(base_url().'admin/profile/update',array('class' => 'form-horizontal')); ?> <div class="box box-info"> <div class="box-body"> <div class="form-group"> <label for="" class="col-sm-2 control-label">Display Name <span>*</span></label> <div class="col-sm-4"> <input type="text" class="form-control" name="name" value="<?php echo $this->session->userdata('name'); ?>"> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label">Email Address <span>*</span></label> <div class="col-sm-4"> <input type="text" class="form-control" name="email" value="<?php echo $this->session->userdata('email'); ?>"> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label">Phone <span>*</span></label> <div class="col-sm-4"> <input type="text" class="form-control" name="phone" value="<?php echo $this->session->userdata('phone'); ?>"> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label"></label> <div class="col-sm-6"> <button type="submit" class="btn btn-success pull-left" name="form1">Update Information</button> </div> </div> </div> </div> <?php echo form_close(); ?> </div> <div class="tab-pane" id="tab_2"> <?php echo form_open_multipart(base_url().'admin/profile/update',array('class' => 'form-horizontal')); ?> <div class="box box-info"> <div class="box-body"> <div class="form-group"> <label for="" class="col-sm-2 control-label">Existing Photo</label> <div class="col-sm-6" style="padding-top:6px;"> <?php if($this->session->userdata('photo') ==''): ?> <img src="<?php echo base_url(); ?>public/img/no-photo.jpg" class="existing-photo" alt="profile photo" width="140"> <?php else: ?> <img src="<?php echo base_url(); ?>public/uploads/<?php echo $this->session->userdata('photo'); ?>" class="existing-photo" width="140"> <?php endif; ?> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label">New Photo</label> <div class="col-sm-6" style="padding-top:6px;"> <input type="file" name="photo"> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label"></label> <div class="col-sm-6"> <button type="submit" class="btn btn-success pull-left" name="form2">Update Photo</button> </div> </div> </div> </div> <?php echo form_close(); ?> </div> <div class="tab-pane" id="tab_3"> <?php echo form_open(base_url().'admin/profile/update',array('class' => 'form-horizontal')); ?> <div class="box box-info"> <div class="box-body"> <div class="form-group"> <label for="" class="col-sm-2 control-label">Password </label> <div class="col-sm-4"> <input type="password" class="form-control" name="password"> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label">Retype Password </label> <div class="col-sm-4"> <input type="password" class="form-control" name="re_password"> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label"></label> <div class="col-sm-6"> <button type="submit" class="btn btn-success pull-left" name="form3">Update Password</button> </div> </div> </div> </div> <?php echo form_close(); ?> </div> </div> </div> </div> </div> </section> Here is my controller - Profile.php <?php defined('BASEPATH') OR exit('No direct script access allowed'); class Profile extends CI_Controller { function __construct() { parent::__construct(); $this->load->model('admin/Model_common'); $this->load->model('admin/Model_profile'); } public function index() { $data['setting'] = $this->Model_common->get_setting_data(); $this->load->view('admin/view_header',$data); $this->load->view('admin/view_profile',$data); $this->load->view('admin/view_footer'); } public function update() { $error = ''; $success = ''; $data['setting'] = $this->Model_common->get_setting_data(); if(isset($_POST['form1'])) { $valid = 1; $this->form_validation->set_rules('email', 'Email Address', 'trim|required|valid_email'); if($this->form_validation->run() == FALSE) { $valid = 0; $error = validation_errors(); } if($valid == 1) { $form_data = array( 'email' => $_POST['email'], 'name' => $_POST['name'], 'phone' => $_POST['phone'] ); $this->Model_profile->update($form_data); $success = 'Profile Information is updated successfully!'; $this->session->set_userdata($form_data); $this->session->set_flashdata('success',$success); redirect(base_url().'admin/profile'); } else { $this->session->set_flashdata('error',$error); redirect(base_url().'admin/profile'); } } if(isset($_POST['form2'])) { $valid = 1; $path = $_FILES['photo']['name']; $path_tmp = $_FILES['photo']['tmp_name']; if($path!='') { $ext = pathinfo( $path, PATHINFO_EXTENSION ); $file_name = basename( $path, '.' . $ext ); $ext_check = $this->Model_common->extension_check_photo($ext); if($ext_check == FALSE) { $valid = 0; $data['error'] = 'You must have to upload jpg, jpeg, gif or png file<br>'; } } else { $valid = 0; $data['error'] = 'You must have to select a photo<br>'; } if($valid == 1) { // removing the existing photo unlink('./public/uploads/'.$this->session->userdata('photo')); // updating the data $final_name = 'user-'.'.'.$ext; move_uploaded_file( $path_tmp, './public/uploads/'.$final_name ); $form_data = array( 'photo' => $final_name ); $this->Model_profile->update($id,$form_data); $success = 'Photo is updated successfully!'; $this->session->set_userdata($id,$form_data); $this->session->set_flashdata('success',$success); redirect(base_url().'admin/profile'); } else { $this->session->set_flashdata('error',$error); redirect(base_url().'admin/profile'); } } if(isset($_POST['form3'])) { $valid = 1; $this->form_validation->set_rules('password', 'Password', 'trim|required'); $this->form_validation->set_rules('re_password', 'Retype Password', 'trim|required|matches[password]'); if($this->form_validation->run() == FALSE) { $valid = 0; $error = validation_errors(); } if($valid == 1) { $form_data = array( 'password' => md5($_POST['password']) ); $this->Model_profile->update($id,$form_data); $success = 'Password is updated successfully!'; $this->session->set_userdata($id,$form_data); $this->session->set_flashdata('success',$success); redirect(base_url().'admin/profile'); } else { $this->session->set_flashdata('error',$error); redirect(base_url().'admin/profile'); } } $data['setting'] = $this->Model_common->get_setting_data(); $this->load->view('admin/view_header',$data); $this->load->view('admin/view_profile',$id,$data); $this->load->view('admin/view_footer'); } } And finally, my Model_profile.php (only need to update) No errors etc. Any help would be appreciated. Cheers, Dan <?php defined('BASEPATH') OR exit('No direct script access allowed'); class Model_profile extends CI_Model { function update($id) { $this->db->where('id',$id); $this->db->update('tbl_team_member',$data); } }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.