get selected form_dropdown codeigniter from database - codeigniter

i am new with codeigniter, and i am trying to set selected value from database,
this code doesn't work,
<?php
$options = array(
'one' => 'one',
'two' => 'two',
);
$selected = $teach->number;
echo form_dropdown('number', $options, $selected);
?>
but when i try to manual, it work.
<?php
$options = array(
'one' => 'one',
'two' => 'two',
);
$selected = 'one';
echo form_dropdown('number', $options, $selected);
?>
I don't know why,
Any advice would be great. Thanks
this my controller
public function index() {
$this->load->helper('url');
$id = $this->uri->segment(3);
$this->data['teach'] = $this->EditTeachModel->getPosts(); // calling Post model method getPosts()
$this->data['singleTeach'] = $this->EditTeachModel->getPostsId($id); // calling Post model method getPosts()
//view
$this->load->view('edit_teach', $this->data); // load the view file , we are passing $data array to view file
}
public function update(){
$id = $this->input->post('kd');
$this->load->library('form_validation');
$data = array(
'kd' => $this->input->post('kd'),
'name' => $this->input->post('name'),
'date' => $this->input->post('date'),
'number' => $this->input->post('number'),
'pass' => $this->input->post('pass')
);
$this->EditTeachModel->updatePosts($id, $data);
$this->index();
}
This my model
public function getPosts(){
$this->db->from('teach');
$query = $this->db->get();
return $query->result();
}
public function getPostsId($data){
$this->db->select('*');
$this->db->from('teach');
$this->db->where('kd', $data);
$query = $this->db->get();
$result = $query->result();
return $result;
}
public function updatePosts($id, $data){
$this->db->where('kd', $id);
$this->db->update('teach', $data);
}
this my view
<?php foreach($singleTeach as $teach) {?>
<form method="post" action="<?php echo base_url() . "edit_teach/update"?>">
<div class="card-body"><td>
<div class="row">
<div class="col-6">
<div class="form-group">
<label id="kd">Kode :</label>
<input type="text" id="kd" name="kd" class="form-control" value="<?php echo $teach->kd; ?>">
</div>
<div class="form-group">
<label id="name">Nama:</label>
<input type="text" id="name" name="name" class="form-control" value="<?php echo $teach->name; ?>">
</div>
<div class="form-group">
<label id="date">Date :</label>
<input type="text" id="date" name="date" class="form-control" value="<?php echo $teach->date; ?>">
</div>
<div class="form-group">
<?php echo form_label('Number '); ?> <?php echo form_error('number'); ?>
<?php
$options = array(
'one' => 'one',
'two' => 'two',
);
$selected = $teach->number;
print_r($teach);
echo form_dropdown('number', $options, $selected);
?>
</div>
<div class="form-group">
<label id="pass">Password :</label>
<input type="text" id="pass" name="pass" class="form-control" value="<?php echo $teach->pass; ?>">
</div>
</div>
</div>
</div>
<!-- /.card-body -->
<div class="card-footer">
<?php echo form_submit(array('id' => 'submit','class'=> 'btn btn-primary', 'value' => 'Submit')); ?>
</div>
</form>
<?php } ?>

Related

Item value not updating, Codeigniter

I'm new at using codeigniter and I'm trying to update the item value in my database but it's not working. I can't figure out what to do because when I clicked the save button, the page redirects to the /packages(where the list of packages are displayed) but the item isn't updated. Here's my controller
public function update_package($id)
{
$this->form_validation->set_rules('title', 'Package Name', 'required');
$this->form_validation->set_rules('tour_location', 'Inclusions', 'trim');
$this->form_validation->set_rules('description', 'Description', 'trim|required');
$this->form_validation->set_rules('cost', 'Price', 'required');
$this->form_validation->set_rules('status', 'Status', 'required');
if ($this->form_validation->run() == true) {
$current_image = $this->input->post('current_image');
$new_image = $_FILES['image']['name'];
if ($new_image == TRUE) {
$update_image = time() . "-" . str_replace(' ', '-', $_FILES['image']['name']);
$config = [
'upload_path' => './images',
'allowed_types' => 'gif|jpg|png',
'file_name' => $update_image,
];
$this->load->library('upload', $config);
if (!$this->upload->do_upload('image')) {
if (file_exists('./images' . $current_image)) {
unlink('./images' . $current_image);
}
}
} else {
$update_image = $current_image;
}
$packageData = array(
'title' => $this->input->post('title'),
'tour_location' => $this->input->post(htmlentities('tour_location')),
'description' => $this->input->post(htmlentities('description')),
'cost' => $this->input->post('cost'),
'status' => $this->input->post('status'),
'upload_path' => $update_image
);
$img = new Admin_model;
$img->update($packageData, $id);
$this->session->set_flashdata('status', 'Package InsertedSuccesfully');
redirect(base_url('admin/edit_package/'.$id));
} else {
return $this->edit_package($id);
}
}
My model
public function update($data, $id) {
// Update member data
return $this->db->update("packages", $data ,array('id' => $id));
}
View
<div class="card-body">
<small><?php echo validation_errors(); ?></small>
<form action="<?= base_url('admin/packages') ?>" method="POST" enctype="multipart/form-data">
<div class="form-group">
<label for="name" class="control-label">Package Name</label>
<input type="text" class="form-control mb-3" name="title" placeholder="Enter Package Name" value="<?php echo !empty($packages->title) ? $packages->title : ''; ?>">
</div>
<div class="form-group">
<label for="short_name" class="control-label">Inclusions</label>
<textarea id="compose-textarea" class="form-control" name="tour_location" style="height: 300px;"><?php echo !empty($packages->tour_location) ? $packages->tour_location : ''; ?></textarea>
</div>
<div class="form-group">
<label for="short_name" class="control-label">Description</label>
<textarea id="compose-textarea2" class="form-control" name="description" style="height: 300px;"><?php echo !empty($packages->description) ? $packages->description : ''; ?></textarea>
</div>
<div class="form-group">
<label for="price" class="control-label">Price</label>
<input type="number" step="any" class="form-control form" required name="cost" value="<?php echo !empty($packages->cost) ? $packages->cost : 0; ?>">
</div>
<div class="form-group">
<label for="status" class="control-label">Status</label>
<select name="status" id="status" class="custom-select select">
<option value="1" <?php echo isset($status) && $status == 1 ? 'selected' : '- Select Status -' ?>>Active</option>
<option value="0" <?php echo isset($status) && $status == 0 ? 'selected' : '- Select Status -' ?>>Inactive</option>
</select>
</div>
<div class="form-group">
<label for="short_name" class="control-label">Images</label>
<div class="custom-file">
<label class="btn custom-file-label text-light" for="customFile">Choose file
<input type="hidden" name="current_image" value="<?php echo !empty($packages->upload_path) ? $packages->upload_path : ''; ?>">
<input type="file" class="form-control custom-file-input" id="customFile" name="image" multiple accept="image/*">
<small><?php if (isset($error)) {
echo $error;
} ?></small>
</label>
</div>
</div>
<div class="col-md-4">
<img src="<?php echo base_url('images/'.$packages->upload_path) ?>" alt="Package Image" class="w-100 h-100">
</div>
<div class="card-footer">
<input type="submit" name="packageData" class="btn btn-success " value="Save">
<a class="btn btn-flat btn-default" href="admin/packages">Cancel</a>
</div>
</form>
</div>
<script>
$("#submit").click(function(e) {
e.preventDefault();
$('#packageData').submit();
});
</script>

Changing password of the signed in user in code igniter

I am working on Code Igniter and stuck in a place where I need to change the password of a signed-in user. I need help in picking up the user id of the signed-in user and through it I want to update the password of that user.
The following are the images of controller and models created of the project respectively.
Create html link:
<i class="fa fa-circle-o"></i>Change password
Create user controller:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class User extends CI_Controller
{
public function __construct()
{
parent::__construct();
// Load form helper library
$this->load->helper('form');
// Load form validation library
$this->load->library('form_validation');
// Load session library
$this->load->library('session');
$this->load->model('Data_model');
}
public function changePassword()
{
$web = array();
$web['title'] = 'Change password';
$web['content'] = 'web/password';
$this->form_validation->set_rules('old_password', 'Old password', 'required|callback_check_password');
$this->form_validation->set_rules('new_password', 'New password', 'required');
$this->form_validation->set_rules('confirm_password', 'Confirm password', 'required|matches[new_password]');
if ($this->form_validation->run() == FALSE) {
$this->load->view('web_template',$web);
} else {
$id = $this->user_id;
$data = array(
'user_password' => $this->input->post('new_password'),
);
$this->Common_model->Data_model('user_login', $data, 'id', $id);
$this->session->set_flashdata('msg', 'Password changed Successfully');
redirect('user/changePassword');
}
}
function check_password($password) {
if($this->user_id)
$id = $this->user_id;
else
$id = '';
$result = $this->Data_model->check_user_password($id, $password);
if($result > 0)
$response = true;
else {
$this->form_validation->set_message('check_password', 'Old password is wrong');
$response = false;
}
return $response;
}
}
Change password html page in view:
<section class="content">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title"><?php echo $title; ?></h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
<i class="fa fa-minus"></i></button>
</div>
</div>
<?php
$attributes = array('class' => 'form-horizontal', 'id' => 'changePassword');
echo form_open('user/changePassword', $attributes);
?>
<div class="box-body">
<?php if (!empty($this->session->flashdata('msg'))) : ?>
<div class="alert alert-success alert-dismissable alertDiv"> <?php echo $this->session->flashdata('msg'); ?> </div>
<?php endif; ?>
<div class="row">
<div class="col-md-offset-2 col-md-8">
<div class="form-group">
<label for="inputEmail3" class="col-md-2 control-label">Old password</label>
<div class="col-md-8">
<input type="password" name="old_password" value="<?php echo (isset($form_data) ? $form_data->old_password : set_value('old_password')); ?>" class="form-control" id="old_password" placeholder="Old password">
<?php echo form_error('old_password', '<div class="error">', '</div>'); ?>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-offset-2 col-md-8">
<div class="form-group">
<label for="inputEmail3" class="col-md-2 control-label">New password</label>
<div class="col-md-8">
<input type="password" name="new_password" value="<?php echo (isset($form_data) ? $form_data->new_password : set_value('new_password')); ?>" class="form-control" id="new_password" placeholder="New password" autocomplete="off">
<?php echo form_error('new_password', '<div class="error">', '</div>'); ?>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-offset-2 col-md-8">
<div class="form-group">
<label for="inputEmail3" class="col-md-2 control-label">Confirm Password</label>
<div class="col-md-8">
<input type="password" name="confirm_password" value="<?php echo (isset($form_data) ? $form_data->confirm_password : set_value('confirm_password')); ?>" class="form-control" id="confirm_password" placeholder="Confirm Password" autocomplete="off">
<?php echo form_error('confirm_password', '<div class="error">', '</div>'); ?>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-offset-5" style="margin-top: 10px;">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
<?php form_close(); ?>
</div>
<!-- /.box -->
</section>
Create Data_model in model add this function:
// Update data to table
public function update($table, $data, $primaryfield, $id)
{
$this->db->where($primaryfield, $id);
$q = $this->db->update($table, $data);
return $q;
}
//Check the old password:
function check_user_password($id = '', $password) {
$this->db->where('user_password', $password);
$this->db->where('id', $id);
return $this->db->get('user_login')->num_rows();
}

Codeigniter 3 blog application: update() method deletes thumbnail

I am working on a basic blog application in Codeigniter 3.1.8.
There is a create post and an update post functionality.
When a post is created, there is the option to upload a post thumbnail, else a default image is displayed. In the post controller there is the method for creating posts:
public function create() {
// More code here
if($this->form_validation->run() === FALSE){
$this->load->view('partials/header', $data);
$this->load->view('create');
$this->load->view('partials/footer');
} else {
// Upload image
$config['upload_path'] = './assets/img/posts';
$config['allowed_types'] = 'jpg|png';
$config['max_size'] = '2048';
$this->load->library('upload', $config);
if(!$this->upload->do_upload()){
$errors = array('error' => $this->upload->display_errors());
$post_image = 'default.jpg';
} else {
$data = array('upload_data' => $this->upload->data());
$post_image = $_FILES['userfile']['name'];
}
$this->Posts_model->create_post($post_image);
redirect('posts');
}
}
There is a method for updating posts:
public function update() {
// Form data validation rules
// irrelevant for the question suppressed
$id = $this->input->post('id');
// Upload image
$config['upload_path'] = './assets/img/posts';
$config['allowed_types'] = 'jpg|png';
$config['max_size'] = '2048';
$this->load->library('upload', $config);
$data = array('upload_data' => $this->upload->data());
$this->upload->do_upload();
$post_image = $_FILES['userfile']['name'];
if ($this->form_validation->run()) {
$this->Posts_model->update_post($id, $post_image);
redirect('posts/post/' . $id);
} else {
$this->edit($id);
}
}
In the Posts_model model:
public function update_post($id, $post_image) {
$data = [
'title' => $this->input->post('title'),
'description' => $this->input->post('desc'),
'content' => $this->input->post('body'),
'post_image' => $post_image,
'cat_id' => $this->input->post('category')
];
$this->db->where('id', $id);
return $this->db->update('posts', $data);
}
The edit post view:
<?php echo form_open_multipart(base_url('posts/update')); ?>
<input type="hidden" name="id" id="pid" value="<?php echo $post->id; ?>">
<div class="form-group <?php if(form_error('title')) echo 'has-error';?>">
<input type="text" name="title" id="title" class="form-control" placeholder="Title" value="<?php echo $post->title; ?>">
<?php if(form_error('title')) echo form_error('title'); ?>
</div>
<div class="form-group <?php if(form_error('desc')) echo 'has-error';?>">
<input type="text" name="desc" id="desc" class="form-control" placeholder="Short decription" value="<?php echo $post->description; ?>">
<?php if(form_error('desc')) echo form_error('desc'); ?>
</div>
<div class="form-group <?php if(form_error('body')) echo 'has-error';?>">
<textarea name="body" id="body" cols="30" rows="5" class="form-control" placeholder="Add post body"><?php echo $post->content; ?></textarea>
<?php if(form_error('body')) echo form_error('body'); ?>
</div>
<div class="form-group">
<select name="category" id="category" class="form-control">
<?php foreach ($categories as $category): ?>
<?php if ($category->id == $post->cat_id): ?>
<option value="<?php echo $category->id; ?>" selected><?php echo $category->name; ?></option>
<?php else: ?>
<option value="<?php echo $category->id; ?>"><?php echo $category->name; ?></option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
<label for="postimage">Upload an image</label>
<div class="form-group">
<input type="file" name="userfile" id="postimage" size="20">
</div>
<div class="form-group">
<input type="submit" value="Save" class="btn btn-block btn-md btn-success">
</div>
<?php echo form_close(); ?>
The problem with the update() method is that, when editing a post, unless I replace it's existing thumbnail with a new one (in other words, if I let the file upload field empty), results in leaving the post without a thumbnail:
<img src="http://localhost/ciblog/assets/img/posts/">
What I have tried (not the best idea, I admit) is to fetch the name pg the file already existing in the posts table this way:
$data['post'] = $this->Posts_model->get_post($id);
$post_image = $data['post']->post_image;
But it gives the error Trying to get property of non-object.
What am I doing wrong?
Solved it:
In the edit post form, I have added an input of type hidden above the file input, in order to "capture" the posts image from the database:
<input type="hidden" name="postimage" id="postimage" value="<?php echo $post->post_image; ?>">
<label for="postimage">Upload an image</label><div class="form-group">
<input type="file" name="userfile" id="postimage" size="20">
</div>
In the Posts controller, I have replaced
$data = array('upload_data' => $this->upload->data());
$this->upload->do_upload();
$post_image = $_FILES['userfile']['name'];
with:
if(!$this->upload->do_upload()){
$errors = array('error' => $this->upload->display_errors());
$post_image = $this->input->post('postimage');
} else {
$data = array('upload_data' => $this->upload->data());
$post_image = $_FILES['userfile']['name'];
}
The code above means: if no new image is uploaded, write the name of the existing one in the posts table again, instead of writing nothing. If instead a new photo is uploaded, write the name of the new photo.

Trying to fetch image from database in codeigniter

I was uploaded Image in database Successfully. But not succeed to fetch image from database.
i want to fetch the image from database.
here is my code,
controller -> login.php
public function user_update(){
$this->load->model('login_model');
$this->form_validation->set_rules('fname', 'First Name','required');
$this->form_validation->set_rules('lname', 'Last Name','required');
$this->form_validation->set_rules('cnumber', 'Contact Number','required|min_length[10]|max_length[10]|numeric');
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'doc|docx|pdf|gif|jpg|png|xlsx';
$config['max_size'] = 10000;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$this->load->library('upload', $config);
if (( ! $this->upload->do_upload('image')) && ($this->form_validation->run() === FALSE ))
{
$this->load->view('student/home');
}
else
{
$data = array('upload_data' => $this->upload->data());
$image_name=($data['upload_data']['file_name']);
$resume=base_url().$image_name;
$udata = array(
'id' => $this->input->post('id'),
'fname' => $this->input->post('fname'),
'mname' => $this->input->post('mname'),
'lname' => $this->input->post('lname'),
'email' => $this->input->post('email'),
'address' => $this->input->post('address'),
'cnumber' => $this->input->post('cnumber'),
'image'=> $resume
);
$this->login_model->Updateuser($udata);
}
}
model file:- login_model.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class login_model extends CI_Model
{
function Updateuser($param) {
$id = $param['id'];
$usar1 = array(
'Student_Name' => $param['fname'],
'm_name' => $param['mname'],
'l_name' => $param['lname'],
'Student_Email' => $param['email'],
'contact_no' => $param['cnumber'],
'Address' => $param['address'],
'image' => $param['image']
);
$this->db->where('Student_id', $id);
$this->db->update('students', $usar1);
//echo ($this->db->last_query());
//exit();
$sturesult = $this->login_model->get_student_list();
$data['Stulist'] = $sturesult;
$this->load->view('student/default_list',$data);
}
}
view file:- edit_info.php
<div class="container" id='main-layout' style="border-top: 1px solid #D14B54; background: #f5f5f5f5">
<div class="row">
<div class="col-md-8 col-sm-8">
<div class="ajaxResponse"><input type="hidden" name="ajaxResponse"></div>
<div class="row" style="padding: 10px 5px;">
<?php $id = $this->uri->segment(3); if(!empty($id)): ?>
<div class="">
<?php echo validation_errors();
echo $lname;
?>
<div class="thumbnail familycol" style="padding:16px">
<?php echo form_open_multipart('login/user_update'); ?>
<legend>Personal Information</legend>
<div class="row">
<?php //echo form_label('Id :'); ?> <?php echo form_error('id'); ?>
<input type="hidden" name="id" value="<?php echo $row->Student_id; ?>" class="form-control input-sm" placeholder="id"/>
<!-- <label class="required">First name</label>-->
<div class="col-xs-6 col-md-6">
<label for="First Name">First Name:</label>
<input type="input" name="fname" class="form-control" value="<?php echo $row->Student_Name;?>"/><font color="red"><?php echo form_error('fname'); ?></font>
</div>
<div class="col-xs-6 col-md-6">
<!--<label class="required">Middle name</label>-->
<label for="Last Name">Middle Name:</label>
<input type="input" name="mname" class="form-control" value="<?php echo $row->m_name?>"/><font color="red"><?php echo form_error('mname'); ?></font>
</div>
</div>
<div class="row">
<div class="col-xs-6 col-md-6">
<!--<label class="required">Last name</label>-->
<label for="Last Name">Last Name:</label>
<input type="input" name="lname" class="form-control" value="<?php echo $row->l_name ;?>"/><font color="red"><?php echo form_error('lname'); ?></font>
</div>
<div class="col-xs-6 col-md-6">
<?php echo form_label('Email :'); ?> <?php echo form_error('email'); ?>
<input type="text" name="email" value="<?php echo $row->Student_Email; ?>" class="form-control input-sm" placeholder="Email" />
</div>
</div>
<br>
<div class="row">
<div class="col-sm-6">
<!--<label>Address</label>-->
<label for="text">Address</label>
<textarea name="address" class="form-control"><?php echo $row->Address ;?></textarea><font color="red"><?php echo form_error('address'); ?></font>
</div>
<div class="col-sm-6">
<label for="text">Contact Number</label>
<textarea name="cnumber" class="form-control"><?php echo $row->contact_no ;?></textarea><font color="red"><?php echo form_error('cnumber'); ?></font>
</div>
<br/>
</div>
<br/>
<label for='uploaded_file'>Select A File To Upload:</label>
<input type="file" name="image" accept="image/*" value="upload">
<br/>
<button class="btn btn-lg btn-primary btn-block signup-btn" type="submit" style="margin-top: 5px;">
Update my Profile</button>
</div>
</div>
<?php endif;?>
</div>
</div>
</div>
</div>
Ok Lets Put Code in your View file:
<img src="<?php echo base_url('uploads/').$Stulist[$i]->image; ?>"
You have updated the wrong image directory of uploaded images in database.
Simply update the following lines of code
$data = array('upload_data' => $this->upload->data());
$image_name=($data['upload_data']['file_name']);
$resume=base_url().$image_name;
to
$data = array('upload_data' => $this->upload->data());
$image_name=($data['upload_data']['file_name']);
$resume=base_url('uploads').$image_name;
here the base_url points to the uploads directory where you have uploaded your images.

OUTPUGet street1 and street 2 Magento

How I can get street address 1 and street address 2 value. I create an extension and I want to get street address in Magento. In the block I have this function:
public function updateFormData() {
$data = $this->getData('form_data');
if (is_null($data)) {
/** #var array $formData */
$formData = Mage::getSingleton('customer/session')->getCustomerFormData(true);
$order = $this->getOrder();
$address = $order->getShippingAddress();
$customerData = [
'email' => $order->getCustomerEmail(),
'firstname' => $order->getCustomerFirstname(),
'lastname' => $order->getCustomerLastname(),
'city' => $order->getBillingAddress()->getCity(),
'country' => $order->getBillingAddress()->getCountry(),
'telephone' => $order->getBillingAddress()->getTelephone(),
'company' => $order->getBillingAddress()->getCompany(),
];
$data = new Varien_Object();
if ($formData) {
$data->addData($formData);
$data->setCustomerData(1);
}
$data->addData($customerData);
if (isset($data['region_id'])) {
$data['region_id'] = (int)$data['region_id'];
}
$this->setData('form_data', $data);
}
return $data;
}
and in the phtml file I add this:
<?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
<li class="wide">
<label for="street_1" class="required"><em>*</em><?php echo $this->__('Street Address') ?></label>
<div class="input-box">
<input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getFormData()->getStreet(1)) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Street Address')) ?>" id="street_1" class="input-text <?php echo $_streetValidationClass ?>" />
</div>
</li>
<?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
<?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
<li class="wide">
<div class="input-box">
<input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getFormData()->getStreet($_i)) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Street Address %s', $_i)) ?>" id="street_<?php echo $_i ?>" class="input-text <?php echo $_streetValidationClass ?>" />
</div>
</li>
<?php endfor; ?>
I try to add this 'street_1' => $order->getBillingAddress()->getData('street'),
But always street_1 address value is blank. I try to get all fields in the order success page.
OUTPUT:
<li class="wide">
<label class="required" for="street_1">
<div class="input-box">
<input id="street_1" class="input-text required-entry" type="text" title="Street Address" value="address1 address2" name="street[]">
</div>
</li>
<li class="wide">
<div class="input-box">
<input id="street_2" class="input-text " type="text" title="Street Address 2" value="" name="street[]">
</div>
</li>
$order->getBillingAddress()->getData('street') will return an array.
So you can access the data with:
$billingStreet = $order->getBillingAddress()->getData('street');
$billingStreet1 = $billingStreet[0];
$billingStreet2 = $billingStreet[1];
$billingStreet3 = $billingStreet[2];
edit: the code above is to get the billing address of an order, what I think you want now is actually the new address, the data set in the form. So this should give you the information you're after, as long as you put it before the $data = new Varien_Object(); line:
$streetArray = $data['street'];
$street1 = $streetArray[0];
$street2 = $streetArray[1];
so your function will be:
public function updateFormData() {
$data = $this->getData('form_data');
if (is_null($data)) {
/** #var array $formData */
$formData = Mage::getSingleton('customer/session')->getCustomerFormData(true);
$order = $this->getOrder();
$address = $order->getShippingAddress();
$streetArray = $data['street'];
$street1 = $streetArray[0];
$street2 = $streetArray[1];
$customerData = [
'email' => $order->getCustomerEmail(),
'firstname' => $order->getCustomerFirstname(),
'lastname' => $order->getCustomerLastname(),
'city' => $order->getBillingAddress()->getCity(),
'country' => $order->getBillingAddress()->getCountry(),
'telephone' => $order->getBillingAddress()->getTelephone(),
'company' => $order->getBillingAddress()->getCompany(),
'street_1' => $street1,
'street_2' => $street2
];
$data = new Varien_Object();
if ($formData) {
$data->addData($formData);
$data->setCustomerData(1);
}
$data->addData($customerData);
if (isset($data['region_id'])) {
$data['region_id'] = (int)$data['region_id'];
}
$this->setData('form_data', $data);
}
return $data;
}

Resources