Simple Form Post with PHP to another Server

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
hbasoft
New php-forum User
New php-forum User
Posts: 2
Joined: Sat Sep 29, 2018 2:11 pm

Sat Sep 29, 2018 2:23 pm

Hello Developers!

I' have an issue which is passing a POST request with a simple form that contains two fields "name" and "captcha".

Code: Select all

<form method="POST" action="http://servername.io/login.php">
<input name="name">
<input name="captcha" type="number">
</form>
 
When i run this code inside a single HTML file (directly from the browser file:///.....), it works perfectly without any problems. However, if i put this code inside a PHP file without any further script, the destination server shows an error message:
An error occurred while handling the request.
I need the PHP solution because i need to set values to these fields from my database.

I think it's a PHP session passing problem or something like that. Please help me to resolve this issue. Thanks!

chorn
php-forum Fan User
php-forum Fan User
Posts: 562
Joined: Fri Apr 01, 2016 2:18 am

Sun Sep 30, 2018 11:27 pm

Have a look in your servers logfiles, there must be a more specific error message.

User avatar
benanamen
New php-forum User
New php-forum User
Posts: 55
Joined: Mon Oct 16, 2017 1:06 pm

Mon Oct 01, 2018 11:01 am

As of this post, http://servername.io is not valid. Also, your inputs have no values.
The XY Problem
The XY problem is asking about your attempted solution (X) rather than your actual problem (Y). This leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help.

hbasoft
New php-forum User
New php-forum User
Posts: 2
Joined: Sat Sep 29, 2018 2:11 pm

Wed Oct 03, 2018 6:35 am

Thanks for the answers :)

I just want to say why when i do a post request from a local Html page (not a php file) to an external Server which works with PHP engine, it works without any problems ?? However, if i upload the same page to my server (a PHP server like Apache) then i make a post request, the destination server refuses this request ! Why ?

To resume :

1- When i start a post request from my computer (file:///C:/connect.html) to an external PHP Server => It works
2- A Post Request from my PHP server (******.alwaysdata.net/**** or local PHP Server) to the external PHP Server => It fails. :(

Is there any further informations are transmitted with my form fields when i use a PHP Server (Like Session informations or something like that) ? If it's true how to get rid of them ?

Thanks!

Post Reply