Login A Site With Curl Via POST

I Need Log In A Website via curl and get the index of the page.

    <form method="post">
cURL Test
Please Enter Username and Password/div>
  • UserName
  • Password

It is the website code. How i login this website using curl? I searched it and found a curl script but it doesnt work.

Source: stackoverflow-php