Reputation: 153
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 />
<a href="<?php echo base_url() ?>index.php/user_authentication/user_registration_show">To SignUp Click Here</a>
<?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 />
<a href="http://::1/login/index.php/user_authentication/user_registration_show">To SignUp Click Here</a>
</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?
Upvotes: 0
Views: 405
Reputation: 38642
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';
and Possible duplicate of This Question
Upvotes: 1