form POST not working |
Hi,
First post here so please bear with me. I've had a search and this thread https://forum.codeigniter.com/showthread.php?tid=77603 is pretty close to what I'm seeing. I'm running MAMP on a brand new Mac with OSX 14.2 and I'm trying to port a (very, very) old CI3 based site to CI4. I've a feeling it's over ten years since I wrote it and since it "worked" I rarely touched it except when updating the underlying database and needed to handle another field/database column. The site will never go public, it's simply so I can manage a club's membership. The problem I'm facing is with passing control from a form to a handler, I've not even got to the point . I get the following message: Quote:Firefox can’t establish a connection to the server at localhost:8080. This happens regardless of whether "index.php" is in the URL or not. The form: Code: <form action="http://localhost:8080/public/bgrapp/registration/add" method="post" accept-charset="utf-8"> PHP Code: $routes->post('registration/add', 'Registration::add'); PHP Code: class Registration extends BaseController{ I'm aware that the retrieval of POST data has changed in the intervening years but I can sort that out when I get to it. I'm obviously missing something but obviously I don't know what! TIA
SEE: The part Add News::create() to Create a News Item.
CodeIgniter 4 User Guide - Build Your First Application Create News Items What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
The port number is correct?
localhost:8080 Why your URL contains `public`? Where did you install CodeIgniter? http://localhost:8080/public/bgrapp/registration/add I recommend you read the User Guide. https://codeigniter4.github.io/CodeIgnit...ith-apache
I installed CodeIgniter at /Applications/MAMP/htdocs/bgrapp using manual installation as per https://www.codeigniter.com/user_guide/i...anual.html (I tried following the Composer instructions but couldn't get my head around them - my fault not those of Composer) In Config/App.php I have
PHP Code: public string $baseURL = 'http://localhost:8080/bgrapp/'; One thing I didn't change was adding "127.0.0.1 bgrapp" to /etc/hosts, it's read-only on my system. After I made the initial post I noted that the port number changed from localhost:8888 (the MAMP Apache default) to localhost:8080 but because I'm a new member I couldn't edit the post until a moderator had cleared it. By the time I realised it was late and I needed some sleep. I added this to hpptd-vhosts.conf Code: <VirtualHost *:80> @InsiteFX I actually used form_open('registration/add'); which is how I'd done it in CI3, the form code posted is what was generated. Are you suggesting I ignore the form_xxx() functions and write out the form myself?
Your document root should be "/Applications/MAMP/htdocs/bgrapp/public".
See https://codeigniter4.github.io/CodeIgnit...irtualhost
OK. Made that change and restarted Apache.
Now I when I go to the home page "http://localhost:8888/bgrapp/" I just get a directory listing. Append "public" to the URI and the home page appears. As a test I tried changing the port number for Apache in MAMP to 8080 and it now works. Well, there are other errors but mostly migration issues. The URI still contains "public" but since I'm the only person likely to use this and I can just bookmark the site I'm not overly worried unless it's going to cause problems further down the line.
DocumentRoot "/Applications/MAMP/htdocs/bgrapp/public"
You can add it to your hosts file you need to use notepad as an elevated Administrator
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |