Dalescop, the server being used is "PicLan-IP 2.0.0 (build 175)."
I've confirmed that "cookies" are not being used because no "cookies.txt" file gets placed on my desktop (when I visit other sites that DO use cookies, a file called "cookies.txt" gets placed on my desktop).
This is interesting: in the middle of my script when I've preg_matched the $token, I added "print $token;" and then at the end of my script I have var_dump($data) to see the entire sourcecode of the page I've CURLed. The "token" from the "print $token" is DIFFERENT than the $token in the var_dump!
I cannot figure out what else this page wants! It shouldn't be rocket science. An ordinary web browser simply posts the variables a webserver needs, in this case:
1.) 'controlNumber'=>$token,
2.) 'inputname1'=>"hammer",
-and-
3.) 'inputname2'=>'nail'
Interestingly, the URL has my username and password encoded into it which means it's a "get" request.... but since http://www.website.com/index.php?username=myself&password=password works in an ordinary web browser, it should work fine when I CURL init that same URL.
I can't figure out what else it needs, unless:
a.) My script is wrong
b.) My script is in the wrong order
c.) I have something wrongly duplicated (like, for example, I have "$data = curl_exec($ch);" listed twice.... but maybe that's okay, I don't know)
What are your thoughts, please?
Here's the script as I have it now:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http://www.website.com/index.php?username=myself&password=password');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible, MSIE 10, Windows NT 6.2');
### THIS GETS THE RANDOM NUMBER "TOKEN":
$data = curl_exec($ch);
preg_match('/controlNumber\"\svalue=\"(.*)\"/',$data,$clip);
$token = $clip[1];
### Now that we have the "$token", lets put it in the CURL post:
curl_setopt($ch, CURLOPT_POSTFIELDS, array('controlNumber'=>$token,'inputname1'=>"hammer",'inputname2'=>'nail'));
$data = curl_exec($ch);
### This var_dump should have the result I am seeking
### Unfortunately, the var_dump only shows the same thing as the but instead it does not
### The following var_dump should have the result I am seeking.
### Unfortunately, it does not. It only shows the same
### original website as if I've simply refreshed the page
### as if nothing got POSTed.
var_dump($data);
?>