Form post not working. is there an easier way to get it done?

i’ve read this link, doesnt seem to work BUT i need something really simple, just to accept the post form

to be honest, even the “get” method took me a long time to get it working but i got it done.

for “post” method, just to process the <form with method post. something so simple is like taking hours to do. can someone provide a solution that’s really easy to process / get form post data? i need the “log” and “pwd” as below:

								<form method=post action="http://login.bcz.workers.dev/wp-login.php">
									<input required  class="form-control" name="log" type="text" placeholder="Email Address">
						     
	<input required  class="form-control" name="pwd" type="password" placeholder="Password">
									<div class="row mt-10">
										<div class="col-6">
											<button class="btn btn-primary btn-block">Login</button>
										</div>
										<div class="col-6 d-flex align-items-center justify-content-end">
											<a href="reset.html">Forgot password?</a>
										</div>
									</div>
									
								</form>

How do I simulate post data in form with the dashboard of cloudflare workers?

in “Body” section, how do i do
log=[username]
pwd=[password]

Sorry I’m not sure how to do this.

Let’s just say that creating a secure login feature using workers takes a lot of knowledge to get right.

If you want to add a proper login, then use Cloudflare Access instead and save yourself the headache.

i just need to get the equivalent of PHP _POST['log'] and _POST[‘pwd’] that’s all. how do i get it using cloudflare? the simplest way will do.

it has nothing to do with any secure login feature for now. it’s difficult to explain, anyhow, i just need the log and pwd values

You can see it in the POST example you linked:

    const formData = await request.formData();
    const body = {};
    for (const entry of formData.entries()) {
      body[entry[0]] = entry[1]
    }

That will give you an array of the values in the “body” object.

I guess you know PHP and not Javascript, I’d suggest reading up here.
https://javascript.info/

How do I simulate post data in form with the dashboard of cloudflare workers?

in “Body” section, how do i do
log=[username]
pwd=[password]

Sorry I’m not sure how to do this. I also need this inside the cloudflare workers dashboard

Formdata is generated from the browser forms API, the request is just a text body.

It looks like this:

-----------------------------225555443718213343653688766542
Content-Disposition: form-data; name="username"

John
-----------------------------225555443718213343653688766542
Content-Disposition: form-data; name="password"

Mypassword
-----------------------------225555443718213343653688766542--

Read all about it here: https://javascript.info/formdata