echo form_open('user_authentication/new_user_registration'); rendered wrong url - codeigniter

I have problem about the form_open or any url in my site, maybe this is the new update of codeigniter or what. when I use its rendered a confusing syntax like http://::1/ and my form not working correctly or take me to a blank page. also my css dont work.
here is my php code.
<html>
<?php
if (isset($this->session->userdata['logged_in'])) {
header("location: http://localhost/login/index.php/user_authentication/user_login_process");
}
?>
<head>
<title>Login Form</title>
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/style.css">
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro|Open+Sans+Condensed:300|Raleway' rel='stylesheet' type='text/css'>
</head>
<body>
<?php
if (isset($logout_message)) {
echo "<div class='message'>";
echo $logout_message;
echo "</div>";
}
?>
<?php
if (isset($message_display)) {
echo "<div class='message'>";
echo $message_display;
echo "</div>";
}
?>
<div id="main">
<div id="login">
<h2>Login Form</h2>
<hr/>
<?php echo form_open('user_authentication/user_login_process'); ?>
<?php
echo "<div class='error_msg'>";
if (isset($error_message)) {
echo $error_message;
}
echo validation_errors();
echo "</div>";
?>
<label>UserName :</label>
<input type="text" name="username" id="name" placeholder="username"/><br /><br />
<label>Password :</label>
<input type="password" name="password" id="password" placeholder="**********"/><br/><br />
<input type="submit" value=" Login " name="submit"/><br />
To SignUp Click Here
<?php echo form_close(); ?>
</div>
</div>
</body>
</html>
then here is the view page source. im using google chrome browser
<html>
<head>
<title>Login Form</title>
<link rel="stylesheet" type="text/css" href="http://::1/login/css/style.css">
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro|Open+Sans+Condensed:300|Raleway' rel='stylesheet' type='text/css'>
</head>
<body>
<div id="main">
<div id="login">
<h2>Login Form</h2>
<hr/>
<form action="http://::1/login/index.php/user_authentication/user_login_process" method="post" accept-charset="utf-8">
<div class='error_msg'></div> <label>UserName :</label>
<input type="text" name="username" id="name" placeholder="username"/><br /><br />
<label>Password :</label>
<input type="password" name="password" id="password" placeholder="**********"/><br/><br />
<input type="submit" value=" Login " name="submit"/><br />
To SignUp Click Here
</form> </div>
</div>
</body>
</html>
as you can see the url of css and form are rendered a wrong url. href="http://::1/login/css/style.css"> instead of href="css/style.css">. also the form_open(). whats wrong with this?

Its because of your base_url is empty
How to set base_url()??
In config/config.php set $config['base_url'] = ''; the project URL.
Keeping base_url() empty any harm??
When you in local its ok and fine. But when you host that just add your site URL to it.
$config['base_url'] = 'www.stackoverflow.com';
Take look at this answer
and Possible duplicate of This Question

Related

ErrorException Array to string conversion

i am facing ErrorException Array to string conversion, I am new in laravel. please help me in detail if you can,please help me in detail if you can please help me in detail if you can please help me in detail if you can please help me in detail if you can please help me in detail if you can please help me in detail if you can please help me in detail if you can
This is my code
<?php
namespace App\Http\Controllers;
use Redirect,Response;
use Illuminate\Http\Request;
use App\Models\Test;
use File;
class JsonController extends Controller
{
public function index()
{
return view('json_form');
}
public function download(Request $request)
{
$data = $request->only('name','email','mobile_number');
$test['token'] = time();
$test['data'] = json_encode($data);
Test::insert($test);
$fileName = $test['token']. '_datafile.json';
File::put(public_path('/upload/json/'.$fileName),$test);
//return download(public_path('/upload/jsonfile/'.$fileName));
$headers = [ 'Content-Type' => 'application/json', ];
return response()->download($test, 'filename.json', $headers);
//return response()->download(public_path('file_path/from_public_dir.pdf'));
}
}
This is my jeson.blade.php
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>Laravel Store Data To Json Format In Database - Tutsmake.com</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" />
<style>
.error{ color:red; }
</style>
</head>
<body>
<div class="container">
<h2 style="margin-top: 10px;">Laravel Store Data To Json Format In Database - Tutsmake.com</h2>
<br>
<br>
#if ($message = Session::get('success'))
<div class="alert alert-success alert-block">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>{{ $message }}</strong>
</div>
<br>
#endif
<form id="laravel_json" method="post" action="json-file-download">
#csrf
<div class="form-group">
<label for="formGroupExampleInput">Name</label>
<input type="text" name="name" class="form-control" id="formGroupExampleInput" placeholder="Please enter name">
</div>
<div class="form-group">
<label for="email">Email Id</label>
<input type="text" name="email" class="form-control" id="email" placeholder="Please enter email id">
</div>
<div class="form-group">
<label for="mobile_number">Mobile Number</label>
<input type="text" name="mobile_number" class="form-control" id="mobile_number" placeholder="Please enter mobile number">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success">Submit</button>
</div>
</form>
</div>
</body>
</html>

style.css does not load correctly

This is my code. I wonder why the style sheet does not load up correctly?
admin/views/login.php
<html>
<head>
<meta charset="UTF-8">
<title>CodePen - Log-in</title>
<link rel='stylesheet' href='http://codepen.io/assets/libs/fullpage/jquery-ui.css'>
<link rel="stylesheet" href="<?php echo base_url(''); ?>assets/style.css" media="screen" type="text/css" />
</head>
<body>
<br><br><br><br><br><br>
<?php $this->load->library('form_validation'); ?>
<?php echo validation_errors(); ?>
<?php echo form_open('cpages/ceklogin'); ?>
<div class="login-card">
<center><?php //echo $warning; ?>
<?php echo $this->session->flashdata('warning'); ?>
</center>
<h2>Gionda CMS Login</h2><br>
<form>
<div class="login"><input type="text" name="username" placeholder="Username"></div>
<div class="login"><input type="password" name="password" placeholder="Password"></div>
<br>
<input type="submit" name="login" class="login login-submit" value="login">
</form>
<div class="login-help">
Register • Forgot Password
</div>
</div>
<!-- <div id="error"><img src="https://dl.dropboxusercontent.com/u/23299152/Delete-icon.png" /> Your caps-lock is on.</div> -->
<script src='http://codepen.io/assets/libs/fullpage/jquery_and_jqueryui.js'></script>
admin/config/config.php
$config['base_url'] = 'http://localhost/masterlinkci2/admin/';
1.Load url helper in application/config/autoload.php.
$autoload['helper'] = array('url');
2.Then set base_url to url as your root folder.
$config['base_url'] = 'http://localhost/masterlinkci2/';
3.And link your css like this.
<link rel="stylesheet" href="<?php echo base_url('assets/style.css');?>" media="screen" type="text/css" />
Hope it works..
Hey you need to add the path into your baseurl function parameters and not by appending path to it.
<?php echo base_url('') ?>
Instead use the following to add css:
<?php echo base_url('assets/style.css') ?>

Only the first row of a table updates after new details are inserted in a popup form

In each row of a table, I have an “insert” link. When a user clicks this link, a popup window appears containing a form. When the user clicks the “save” button for the form, the form update works only for the first row of the parent table. It takes only the first row ID.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</style>-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Popup contact form using only CSS - Demo | CodingCrazy</title>
<link href="<?php echo base_url();?>assets/css/styleform.css" rel="stylesheet" type="text/css"/>
<link href='http://fonts.googleapis.com/css?family=Electrolize' rel='stylesheet' type='text/css' />
<!--CC-->
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/fonts.css"/>
</head>
</body>
</html>
<!--<link rel="stylesheet" href="<?php // echo base_url();?>assets/css/special.css" type="text/css" />-->
<div class="bal" style="margin-left: 627px;
padding: 15px;">
Balance Amount:<input type="text" name="bal">
<?php echo form_open('money_c/addrow')?>
<input type="submit" style="padding:7px;" name="sub" value="add row">
<?php echo form_close();?></div>
<table border="1">
<tr>
<th>Date</th>
<th>Description</th>
<th>Category</th>
<th>Debit</th>
<th>Credit</th>
<th>Bal.AMT</th>
<th>Insert</th>
<th> EDit/Delete</th></tr>
<?php foreach($query2 as $row)
{
$date=$row->date;
$desc=$row->description;
$credit=$row->credit;
$deb=$row->debit;
$bal=$row->bal;
$cat=$row->category;
$id=$row->id;
?>
<tr><td><?php echo $date;?></td>
<td><?php echo $desc;?></td>
<td><?php echo $credit;?></td>
<td><?php echo $deb;?></td>
<td><?php echo $bal;?></td>
<td><?php echo $cat;?></td>
<td><a href="#pop" >Insert<div id="pop" class="box">
<?php
?>
<!--<form action="" method="post" class="smart-green">-->
<div class="smart-green">
<?php
echo form_open('money_c/manualupdatesave/'.$id)?>///here updation happens only for first row id;
<h1>
<span>Please fill all the texts in the fields.</span>
</h1>
<label>
<span>Date:</span>
<input type="date" name="dat" />
</label>
<label>
<span>Description:</span>
<input name="desc" type="text" />
</label>
<label>
<span>Category:</span><select name="selection">
<?php foreach($query1 as $row1)
{
$cat=$row1->category;
?>
<!--<option value="Job Inquiry">Job Inquiry</option>-->
<option value="<?php echo $cat;?>"><?php echo$cat;?></option>
<?php
}
?>
</select>
</label>
<label>
<span>Debit:</span>
<input type="text" name="deb"></input>
</label>
<label>
<span>Credit:</span>
<input type="text" name="credit"></input>
</label>
<label>
<span> </span>
<input type="submit" style="margin-top:12px" class="button" style="background-color: #004e98;"value="Send" />
</label>
</div>
<?php echo form_close();?>
<!--</form>-->
<div id="close">
<td><img src="<?php echo base_url();?>assets/images/del.jpg" width="60" height="40"></td>
</tr>
<?php
}
?></table>
</tbody>
</table>
My controller:
money_c
function manualupdatesave($id)
{
$a=$this->input->post('dat');
$b=$this->input->post('desc');
$c=$this->input->post('cat');
$d=$this->input->post('deb');
$e=$this->input->post('credit');
$this->money_m->transaction($a,$b,$c,$d,$e,$id);
$this->load->view('header');
$result['query2'] = $this->money_m->selecttrans();
$this->load->view('manualupdate',$result);
$this->load->view('footer');
}
view page: manualupdate.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</style>-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Popup contact form using only CSS - Demo | CodingCrazy</title>
<link href="<?php echo base_url();?>assets/css/styleform.css" rel="stylesheet" type="text/css"/>
<link href='http://fonts.googleapis.com/css?family=Electrolize' rel='stylesheet' type='text/css' />
<!--CC-->
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/fonts.css"/>
</head>
<!--<link rel="stylesheet" href="<?php // echo base_url();?>assets/css/special.css" type="text/css" />-->
<div class="bal" style="margin-left: 627px;
padding: 15px;">
Balance Amount:<input type="text" name="bal">
<?php echo form_open('money_c/addrow')?>
<input type="submit" style="padding:7px;" name="sub" value="add row">
<?php echo form_close();?></div>
<table border="1">
<tr>
<th>Date</th>
<th>Description</th>
<th>Category</th>
<th>Debit</th>
<th>Credit</th>
<th>Bal.AMT</th>
<th>Insert</th>
<th> EDit/Delete</th></tr>
<?php foreach($query2 as $row)
{
$date=$row->date;
$desc=$row->description;
$credit=$row->credit;
$deb=$row->debit;
$bal=$row->bal;
$cat=$row->category;
$id=$row->id;
?>
<tr><td><?php echo $date;?></td>
<td><?php echo $desc;?></td>
<td><?php echo $credit;?></td>
<td><?php echo $deb;?></td>
<td><?php echo $bal;?></td>
<td><?php echo $cat;?></td>
<td><a href="#pop" >Insert<div id="pop" class="box">
<?php
?>
<!--<form action="" method="post" class="smart-green">-->
<div class="smart-green">
<?php
echo form_open('money_c/manualupdatesave/'.$id)?>
<h1>
<span>Please fill all the texts in the fields.</span>
</h1>
<label>
<span>Date:</span>
<input type="date" name="dat" />
</label>
<label>
<span>Description:</span>
<input name="desc" type="text" />
</label>
<label>
<span>Category:</span><select name="selection">
<?php foreach($query1 as $row1)
{
$cat=$row1->category;
?>
<!--<option value="Job Inquiry">Job Inquiry</option>-->
<option value="<?php echo $cat;?>"><?php echo$cat;?></option>
<?php
}
?>
</select>
</label>
<label>
<span>Debit:</span>
<input type="text" name="deb"></input>
</label>
<label>
<span>Credit:</span>
<input type="text" name="credit"></input>
</label>
<label>
<span> </span>
<input type="submit" style="margin-top:12px" class="button" style="background-color: #004e98;"value="Send" />
</label>
</div>
<?php echo form_close();?>
<!--</form>-->
<div id="close">
<td><img src="<?php echo base_url();?>assets/images/del.jpg" width="60" height="40"></td>
</tr>
<?php
}
?></table>
</tbody>
</table>
My popup form:
<?php
echo form_open('money_c/manualupdatesave/'.$id)?>
<h1>
<span>Please fill all the texts in the fields.</span>
</h1>
<label>
<span>Date:</span>
<input type="date" name="dat" />
</label>
<label>
<span>Description:</span>
<input name="desc" type="text" />
</label>
<label>
<span>Category:</span><select name="selection">
<?php foreach($query1 as $row1)
{
$cat=$row1->category;
?>
<!--<option value="Job Inquiry">Job Inquiry</option>-->
<option value="<?php echo $cat;?>"><?php echo$cat;?></option>
<?php
}
?>
</select>
</label>
<label>
<span>Debit:</span>
<input type="text" name="deb"></input>
</label>
<label>
<span>Credit:</span>
<input type="text" name="credit"></input>
</label>
<label>
<span> </span>
<input type="submit" style="margin-top:12px" class="button" style="background-color: #004e98;"value="Send" />
</label>
</div>
<?php echo form_close();?>

I cannot update by inserting details from a popup form

When I click the insert link in the second row it passes the ID of the first. Only the first row is updated.
My controller: money_c:
function addrow()
{
$this->load->view('header');
$this->load->view('manualupdate',$result);
$this->load->view('footer');
}
My view page: manualupdate.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</style>-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Popup contact form using only CSS - Demo | CodingCrazy</title>
<link href="<?php echo base_url();?>assets/css/styleform.css" rel="stylesheet" type="text/css"/>
<link href='http://fonts.googleapis.com/css?family=Electrolize' rel='stylesheet' type='text/css' />
<!--CC-->
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/fonts.css"/>
</head>
<!--<link rel="stylesheet" href="<?php // echo base_url();?>assets/css/special.css" type="text/css" />-->
<div class="bal" style="margin-left: 627px;
padding: 15px;">
<table border="1">
<tr>
<th>Date</th>
<th>Description</th>
<th>Category</th>
<th>Debit</th>
<th>Credit</th>
<th>Bal.AMT</th>
<th>Insert</th>
<th> EDit/Delete</th></tr>
<?php foreach($query2 as $row)
{
$date=$row->date;
$desc=$row->description;
$credit=$row->credit;
$deb=$row->debit;
$bal=$row->bal;
$cat=$row->category;
$id=$row->id;
?>
<tr><td><?php echo $date;?></td>
<td><?php echo $desc;?></td>
<td><?php echo $credit;?></td>
<td><?php echo $deb;?></td>
<td><?php echo $bal;?></td>
<td><?php echo $cat;?></td>
<td><a href="#pop" >Insert<div id="pop" class="box">////here pop up will come////pop up starts
</tr>
<?php
}
?></table>
</tbody>
</table>
Popup:
<div class="smart-green">
<?php
echo
form_open('money_c/manualupdatesave/'.$id)?>
<label>
<span>Date:</span>
<input type="date" name="dat" />
</label>
<label>
<span>Description:</span>
<input name="desc" type="text" />
</label>
<label>
<span>Debit:</span>
<input type="text" name="deb"></input>
</label>
<label>
<span>Credit:</span>
<input type="text" name="credit"></input>
</label>
<label>
<span> </span>
<input type="submit" style="margin-top:12px" class="button" style="background-color: #004e98;"value="Send" />
</label>
</div>
<?php echo form_close();?>//////pop up ends///////////
<!--</form>-->
<div id="close">
model: money_m:
function transaction($a,$b,$c,$d,$e,$id)
{
$this->db->where('id',$id);
$this->db->set('date',$a);
$this->db->set('description',$b);
$this->db->set('debit',$d);
$this->db->set('credit',$e);
// $data=array('date'=>$a,'description'=>$b,'debit'=>$d,'credit'=>$e);
$this->db->update('manualupdate');
}
In form_open('money_c/manualupdatesave/'.$id) I get only the first row ID, not the ID of the second row.
<a href="#pop" >Insert<div id="pop" class="box">
change this line to
<a href="#pop-<?php echo $id;?>" >Insert<div id="pop" class="box">
You you popup code is still not complete (assuming it should look like this)
<div id="#pop-<?php echo $id;?>">
<?php
echo
form_open('money_c/manualupdatesave/'.$id)?>
<label>
<span>Date:</span>
<input type="date" name="dat" />
</label>
<label>
<span>Description:</span>
<input name="desc" type="text" />
</label>
<label>
<span>Debit:</span>
<input type="text" name="deb"></input>
</label>
<label>
<span>Credit:</span>
<input type="text" name="credit"></input>
</label>
<label>
<span> </span>
<input type="submit" style="margin-top:12px" class="button" style="background-color: #004e98;"value="Send" />
</label>
</div>
<?php echo form_close();?>//////pop up ends///////////
<!--</form>-->
<div id="close">

Codeigniter form_open not submitting

I've got the following simple search page. 3 fields (one with fixed value) and submit button. When I click submit nothing happens at all. not even reload or anything. the button does nothing. Ignore the arabic in there, I have a feeling it got to do with arrangements of divs or placement of form_open.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>منزلي</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>support/css/main.css" media="screen" />
</head>
<body>
<div id="header">
<div id="logo">
منزلي
</div>
<ul id="list-nav">
<li>للإتصال بنا </li>
<li>عن الموقع</li>
<li>منازل للبيع</li>
<li>منازل للإيجار</li>
<li>الرئيسية</li>
</ul>
</div>
<?
$this->load->helper('form');
form_open('search/search_properties'); ?>
<div id="center">
المدينة:
<select name="city">
<option>الخبر</option>
<option>الدمام</option>
<option>الظهران</option>
</select>
<br><br>
Type: <input type="text" value="flat" name="propertyType"/> <br><br>
حدود السعر:
<select name="range">
<option> <20000 </option>
<option>20000-30000</option>
<option>30000-40000</option>
<option>40000-50000</option>
<option> >500000 </option>
</select>
<br><br>
<input type="submit" value="بحث"/>
</form>
</div>
<div id="footer">
<p>2012 منزلي ©</p>
</div>
</body>
</html>
Any idea why this is happening?
thanks all for support
<?
$this->load->helper('form');
form_open('search/search_properties'); ?>
should be
<?
$this->load->helper('form');
echo form_open('search/search_properties'); ?>

Resources