Chris Nizzardini, Salt Lake City Utah, Web Developer Specializing in LAMP+Ajax Since 2006

My Blog

Here is my awesome blog. You can find information on programming, linux, documentation, tips for code and database optimization, my thoughts and rants, and whatever else I feel like sharing. Feel free to contribute to the blog by posting comments and asking questions.
Linux

php/linux – performing an http post the easy way

It’s been a while since I added anything so here I go. If you have access to execute shell commands and curl is installed on your linux box then this is by far the easiest way to perform an HTTP POST. Here is the simple code:

exec("curl -d \"poststring=true&easy=yes\" http://www.somedomain.com");

Of course you can jazz this up by turning the post string into a variable a long with the url you are posting to. If you add a second parameter to the exec function such as $result then you can easily get a response from the host you are posting too. I came up with this simple method while working on a project at work. I was having problems getting PHPs built-in curl functionality to work, so this was the next best thing or better.

Related posts:

  1. setup an easy ftp server on debian 3.1 linux

Leave a Reply