附加代码点火器URL

附加代码点火器URL

本文介绍了附加代码点火器URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一个问题,我是CodeIgniter的新手,正在尝试在XAMPP服务器上运行登录代码。我有两个视图。

This is my first question, I am new at CodeIgniter and trying to run a login code at XAMPP server. I have two views.

myform.php

myform.php

<html>
<head>
<title>My Form</title>
</head>
<body>

<?php echo validation_errors(); ?>

<form id="myform" method="post" action="/form/myform" title="Create an Account">


<h5>Username</h5>
<input type="text" name="username" value="<?php echo set_value('username'); ?>"  size="50" />

<h5>Password</h5>
<input type="text" name="password" value="<?php echo set_value('username'); ?>"  size="50" />

<div><input type="submit" value="Submit" /></div>

</form>

</body>
</html>

formsuccess.php

formsuccess.php

<html>
<head>
<title>My Form</title>
</head>
<body>

<h3>Your form was successfully submitted!</h3>

<p><?php echo anchor('form', 'Try it again!'); ?></p>

</body>
</html>

和一个控制器:

<?php

class Form extends CI_Controller {

        public function index()
        {
        $this->load->helper(array('form','url'));

                $this->load->library('form_validation');
                $this->form_validation->set_rules('username', 'Username', 'required');
                $this->form_validation->set_rules('password', 'Password', 'required',
                        array('required' => 'You must provide a %s.')
                );

                if ($this->form_validation->run() == FALSE)
                {

                        $this->load->view('myform');
                }
                else
                {
                        $this->load->view('formsuccess');
                }
        }
}

现在在此运行我的本地主机 localhost / codeigniter / index.php / form /

Now when I run this on my localhost localhost/codeigniter/index.php/form/

它打开myform视图,但是当我单击提交按钮,URL变为 localhost / codeigniter / index.php / form / localhost / codeigniter / index.php / form / 。这意味着它将附加URL。只是为了澄清您的人,这是一个很长的问题。

it opens myform view but when I click on the submit button the URL becomes localhost/codeigniter/index.php/form/localhost/codeigniter/index.php/form/. It means it appends the url. It's a long question just to clarify you people. Please help.

推荐答案

如果您设置了基本网址,则只需更改:

If you set your base url, just change :

<form id="myform" method="post" action="/form/myform" title="Create an Account">

<form id="myform" method="post" action="<?php echo base_url();?>form/myform" title="Create an Account">

这篇关于附加代码点火器URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 02:38