Welcome Guest, Not a member yet? Register   Sign In
Form Action URL Question
#1
Question 

Hi,
I'm new to Codeigniter4. And I have a question about something that I don't understand.
First let me say that the tool bar above is difficult to make out even at 120%, the left most icons are difficult to see. But we'll live with it as-is for now.

I created a form that has an action parameter as follows... 
Code:
<form action="<?= base_url() ?>/users/store">
and the resulting action arrives in the correct controller and method, but the URL has a trailing question mark, as follows...
Code:
http://localhost/ci4/users/store? 
 <= where does this question mark come from? 

Ask me questions if needed, I am more than happy to provide more information.
Thanks,
Charles.
Reply
#2

(This post was last modified: 08-04-2021, 03:18 AM by InsiteFX.)

Did you end your app/Config/App.php base_url with a forward / ?

It could also be the url protocol setting try changing it to another one.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(08-02-2021, 09:04 AM)Charles Luck Wrote: Hi,
I'm new to Codeigniter4. And I have a question about something that I don't understand.
First let me say that the tool bar above is difficult to make out even at 120%, the left most icons are difficult to see. But we'll live with it as-is for now.

I created a form that has an action parameter as follows... 
Code:
<form action="<?= base_url() ?>/users/store">
and the resulting action arrives in the correct controller and method, but the URL has a trailing question mark, as follows...
Code:
http://localhost/ci4/users/store? 
 <= where does this question mark come from? 

Ask me questions if needed, I am more than happy to provide more information.
Thanks,
Charles.

What is your form method? Post or get?
Reply
#4

(This post was last modified: 08-05-2021, 03:24 AM by captain-sensible.)

the way i use form is to include bootstrap layout and submit to a route .

eg
Code:
<?=form_open('contact') ?>

     <div class="form-group">
            <label for="name">Your Email </label>
             <input type="email" class="form-control" id="theirEmail" name ="email" placeholder=" " required ="true">
             </div>


etc etc

   <input type="submit" name="submit" class="btn btn-info"value="submit" />
<?php echo form_close();?>

// i've got <?= csrf_field() ?>   in my form as well but won't complicate it for you

in routes.php i have


Code:
$routes->post('contact','Sendmail::processform');


in the post i'm defining "POST" rather than "GET" get requests usually have a ? in url , so maybe thats something to do with yours .
in the above i'm saying that any FORM POST directed to "contact" will invoke the above & be dealt with a controller called Sendmail and its method processform.



In your controller you can get all the values a web surfer has entered into a form and process then any way you want. In my case some checking/filtering goes on and then if Ok i get sent the values to my email address.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB