简体   繁体   中英

Codeigniter base url is not working

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN''http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>

http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>

<head>    
<title>Jotorres Login Screen | Welcome </title>
</head>
<body>
    <div>
    <div>
    <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr>
    <form name="form1" method="post" action="<?php echo base_url(); ?>/checkLogin.php">
    <td>
    <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
    <tr>
    <td colspan="3"><strong>Member Login </strong></td>
    </tr>
    <tr>
    <td width="78">Username</td>
    <td width="6">:</td>
    <td width="294"><input name="myusername" type="text" id="myusername"></td>
    </tr>
    <tr>
    <td>Password</td>
    <td>:</td>
    <td><input name="mypassword" type="password" id="mypassword"></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type="submit" name="Submit" value="Login"></td>
    </tr>
    </table>
    </td>
</form>
</tr>
</table>
</div>
</div>     

base_url() is specified in Config.php

$config['base_url'] = 'http://localhost:81/myPro/';

When trying to post this form,gets an error - "NetworkError: 500 Internal Server Error,I am a new to php codeigniter,thanks pls help

I think you've missed loading the url helper file. Load the url helper in your config/autoload.php and it should work as expected.

The code to add url helper is as shown below:

$autoload['helper'] = array('url');

使用url帮助器函数site_url(),这是正确的功能。

Make sure you import the library and ensure you've got the right directory structure and controllers figured out. This could be tricky for a beginning user.

CodeIgniter automatically adds the base_url to the action of the form when you use the form helper.

For example, you can use:

<?=form_open('main/login'); ?>

which will produce: http//example.com/main/login

And a correct URL! Pretty simple! :D More information at: http://ellislab.com/codeigniter/user_guide/helpers/form_helper.html

I think this is your url helper problem. you try to assingn it in url_helper.php you also can do this same job config/autoload.php file. you can add this code in your autoload.php

$autoload['helper'] = array('url');

尝试将site_url()替换为base_url() site_url()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM