Welcome Guest, Not a member yet? Register   Sign In
New user, having a couple of issues
#1

[eluser]darkpedro[/eluser]
Hi there. I'm a new user to both PHP and CI. I've gone through the tutorials and a couple of other CI tutorials that I've found.

So, I get stuck on all the forms tutorial for the dumbest reason. For some reason I cannot get a submit button to work. I get everything to display, I can fill things in, but when I click submit, nothing happens.

I'm using
Code:
<php echo form_open('form/submit'); ?&gt;
to open,
Code:
&lt;?php echo form_submit('submit', 'Submit'); ?&gt;
for the button, and
Code:
&lt;?php echo form_close(); ?&gt;
to close but I'm stuck at this point.

Does anyone have any suggestions? Is learning CI alongside of PHP even a good idea? Thanks for your help.

edit:
I've also autoloaded the 'url' and 'form' helpers.
#2

[eluser]Michael Wales[/eluser]
Code:
<php echo form_open('form/submit'); ?&gt;

Should be:

Code:
&lt;?php echo form_open('form/submit'); ?&gt;

Note the &lt;?php. That's the only thing I see - everything else looks good. If this doesn't fix it, mind pasting your entire method for us to view?
#3

[eluser]darkpedro[/eluser]
Oops. Didn't see that. It didn't work though.

I've got a slightly modified version of the godbit tutorial, listed below. I've had the same problem on your drunk tutorial (nice one btw).

Code:
&lt;?php
    class Regform extends Controller {
        function index() {
            #Validations
            $this->load->library('validation');
            $rules['fname'] = "required";
            $rules['email'] = "required|valid email";
            $rules['contact'] = "required";
            $this->validation->set_rules($rules);

            #Input and textarea field attributes
            $data['fname'] = array('name' => 'fname', 'id' => 'fname');
            $data['email'] = array('name' => 'email', 'id' => 'email');
            $data['comments'] = array('name' => 'comments', 'id' => 'comments');
            
            #checkboxes attributes
            $data['subscribe'] = array('name' => 'subscribe[]', 'id' => 'contype', 'value' => 'Subscribe to Newsletter', 'checked' => FALSE);
            $data['inquiry'] = array('name' => 'inquiry[]', 'id' => 'contype', 'value' => 'Have Any Questions?', 'checked' => FALSE);
            $data['problem'] = array('name' => 'problem[]', 'id' => 'contype', 'value' => 'Encounter Any Problmes?', 'checked' => FALSE);
            
            if ($this->validation->run() == FALSE)
            {
                $this->load->view('regform_view', $data);
            }
            else
            {
                $fname = $this->input->post('fname');
                $email = $this->input->post('email');
                $comments = $this->input->post('comments');
                $seminars = "";
                
                foreach($this->input->post('contype') as $value){
                $seminars .= "$value\n";
                }
                
                $message = "User $fname ($email) contact:\n$contype and had this to say:\n\n$comments";
                $this->email->from($email, $fname);
                $this->email->to('[email protected]');
                
                $this->email->subject('User Contact');
                $this->email->message($message);
                
                $this->email->send();
                
                $this->load->view('formsuccess');
            }    
        }
    }
?&gt;

And
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Contact PostHive&lt;/title&gt;
&lt;style type="text/css"&gt;
body {
    font: small/1.5em Verdana, Arial, Helvetica, serif;
}
&lt;/style&gt;
&lt;/head&gt;
    &lt;body&gt;
        <h1>Contact PostHive</h1>
        <p>Please use the form below to contact PostHive</p>
        &lt;?php echo form_open('form/submit'); ?&gt;
        <p><label for="fname">Full Name: </label><br/>&lt;?php echo form_input($fname); ?&gt;</p>
        <p><label for="email">Email Address:</label><br/>&lt;?php echo form_input($email); ?&gt;</p>
        
        <p>Please select:</p>
        &lt;?php echo form_checkbox($subscribe); ?&gt;<label for="subscribe">Subscribe to Newsletter</label></p>
        &lt;?php echo form_checkbox($inquiry); ?&gt;<label for="inquiry">Have Any Questions?  How Can We Help?</label></p>
        &lt;?php echo form_checkbox($problem); ?&gt;<label for="problem">Come Across Any Problems?</label></p>
        <p><label for="comments">Comments:</label><br/>&lt;?php echo form_textarea($comments);?&gt;</p>
        &lt;?php echo form_submit('submit', 'Booya'); ?&gt;
        &lt;?php echo form_close(); ?&gt;
    &lt;/body&gt;
&lt;/html&gt;

I appreciate your help.
#4

[eluser]lszanto[/eluser]
Just a suggestion, try taking the form and url helpers out of the autoload and just loading them in the regform class. I can't think of anything else to suggest sorry.
#5

[eluser]darkpedro[/eluser]
Hmm. It appears that I may have mis-spoke. I do have action now. It may have taken a refresh after I added the ? to the &lt;?php.

Thanks for your help guys.
#6

[eluser]darkpedro[/eluser]
[quote author="lszanto" date="1192980783"]Just a suggestion, try taking the form and url helpers out of the autoload and just loading them in the regform class. I can't think of anything else to suggest sorry.[/quote]
That looks to fix the issue. Anything you guys know of that I need to do to autoload the autoload?
#7

[eluser]Michael Wales[/eluser]
Your autoload should work fine. Try adding those helpers back in (I do it all the time, as can be seen in my tuts) and try again.

Note: When you reload you app - always, always use Ctrl+F5. This ensures your browsing isn't caching anything and you are pulling down the page from the server. Also, if you have caching enabled within CI, turn it off until you are done working on your app.
#8

[eluser]darkpedro[/eluser]
wow, I'm having some real issues. When I try to load those back in, the 'form' helper seems to break the whole damn thing. I keep getting the
Code:
Fatal error: ob_start() [<a href='ref.outcontrol'>ref.outcontrol</a>]: Cannot use output buffering in output buffering display handlers in C:\wamp\www\system\libraries\Exceptions.php on line 160
error on everything I code when I try to auto load it. I've run across this error a few times in my playing around and it's led me to reload all of CI. I'm afraid that's where I am again.

The learning curve on php + CI seems pretty steep. Does it level off fairly quickly?
#9

[eluser]darkpedro[/eluser]
Reloading the entire 5.1.4 fixed this issue.




Theme © iAndrew 2016 - Forum software by © MyBB