'@file_to_upload.png', 'upload_text' => '@text_to_upload' ); */ if ($post != ''){ curl_setopt ($curl, CURLOPT_POSTFIELDS, $post); } $html = curl_exec ($curl); curl_close ($curl); return $html; } // start a session to get a cookie $form['url'] = 'https://voterservices.elections.maryland.gov/VoterSearch'; $form['html'] = getPage($form['url'],'',''); // extract the cookie from the header (see CURLOPT_HEADER) $cookie = cut_part_out('ASP.NET_SessionId=',';',$form['html']); // extract the form elements we will need to post with our data $post['__VIEWSTATE'] = cut_part_out('id="__VIEWSTATE" value="','"',$form['html']); $post['__VIEWSTATEGENERATOR'] = cut_part_out('id="__VIEWSTATEGENERATOR" value="','"',$form['html']); $post['__VIEWSTATEENCRYPTED'] = cut_part_out('id="__VIEWSTATEENCRYPTED" value="','"',$form['html']); $post['__EVENTVALIDATION'] = cut_part_out('id="__EVENTVALIDATION" value="','"',$form['html']); // Voter Info Form Elements //$post['Languages_field'] = 'ctl00$MainContent$listLanguages'; $post['ctl00$MainContent$listLanguages'] = "en"; $post['listLanguages'] = "en"; if (isset($_POST['SearchFirstName'])){ //$post['SearchFirstName_field'] = 'ctl00$MainContent$txtSearchFirstName'; $post['ctl00$MainContent$txtSearchFirstName'] = $_POST['SearchFirstName']; $post['txtSearchFirstName'] = $_POST['SearchFirstName']; }else{ $post['ctl00$MainContent$txtSearchFirstName'] = ''; $post['txtSearchFirstName'] = ''; } if (isset($_POST['SearchLastName'])){ //$post['SearchLastName_field'] = 'ctl00$MainContent$txtSearchLastName'; $post['ctl00$MainContent$txtSearchLastName'] = $_POST['SearchLastName']; $post['ctl00$MainContent$txtSearchLastName'] = $_POST['SearchLastName']; }else{ $post['ctl00$MainContent$txtSearchLastName'] = ''; $post['txtSearchLastName'] = ''; } if (isset($_POST['DOBMonth'])){ //$post['DOBMonth_field'] = 'ctl00$MainContent$txtDOBMonth'; $post['ctl00$MainContent$txtDOBMonth'] = $_POST['DOBMonth']; $post['txtDOBMonth'] = $_POST['DOBMonth']; }else{ $post['ctl00$MainContent$txtDOBMonth'] = ''; $post['txtDOBMonth'] = ''; } if (isset($_POST['DOBDay'])){ //$post['DOBDay_field'] = 'ctl00$MainContent$txtDOBDay'; $post['ctl00$MainContent$txtDOBDay'] = $_POST['DOBDay']; $post['txtDOBDay'] = $_POST['DOBDay']; }else{ $post['ctl00$MainContent$txtDOBDay'] = ''; $post['txtDOBDay'] = ''; } if (isset($_POST['DOBYear'])){ //$post['DOBYear_field'] = 'ctl00$MainContent$txtDOBYear'; $post['ctl00$MainContent$txtDOBYear'] = $_POST['DOBYear']; $post['txtDOBYear'] = $_POST['DOBYear']; }else{ $post['ctl00$MainContent$txtDOBYear'] = ''; $post['txtDOBYear'] = ''; } if (isset($_POST['SearchZipCode'])){ //$post['SearchZipCode_field'] = 'ctl00$MainContent$txtSearchZipCode'; $post['ctl00$MainContent$txtSearchZipCode'] = $_POST['SearchZipCode']; $post['txtSearchZipCode'] = $_POST['SearchZipCode']; }else{ $post['ctl00$MainContent$txtSearchZipCode'] = ''; $post['txtSearchZipCode'] = ''; } if (isset($_POST['SearchHouseNumber'])){ //$post['SearchZipCode_field'] = 'ctl00$MainContent$txtSearchZipCode'; $post['ctl00$MainContent$txtSearchHouseNumber'] = $_POST['SearchHouseNumber']; $post['txtSearchHouseNumber'] = $_POST['SearchHouseNumber']; }else{ $post['ctl00$MainContent$txtSearchHouseNumber'] = ''; $post['txtSearchHouseNumber'] = ''; } if (isset($_POST['SearchMiddleInitial'])){ //$post['SearchZipCode_field'] = 'ctl00$MainContent$txtSearchZipCode'; $post['ctl00$MainContent$txtSearchMiddleInitial'] = $_POST['SearchMiddleInitial']; $post['txtSearchMiddleInitial'] = $_POST['SearchMiddleInitial']; }else{ $post['ctl00$MainContent$txtSearchMiddleInitial'] = ''; $post['txtSearchMiddleInitial'] = ''; } // debug - show full response make sure we have the cookie echo "
  • COOKIE ASP.NET_SessionId $cookie
  • "; echo "
  • POST VIEWSTATE $post[__VIEWSTATE]
  • "; echo "
  • POST VIEWSTATEGENERATOR $post[__VIEWSTATEGENERATOR]
  • "; echo "
  • POST VIEWSTATEENCRYPTED $post[__VIEWSTATEENCRYPTED]
  • "; echo "
  • POST EVENTVALIDATION $post[__EVENTVALIDATION]
  • "; echo "
    ";
    echo print_r($post);
    echo "
    "; echo "


    Voter Form

    "; echo htmlspecialchars($form['html']); echo '


    '; //echo $form['html']; ?>
    SearchFirstName
    SearchLastName
    DOBMonth
    DOBDay
    DOBYear
    SearchZipCode
    SearchHouseNumber*
    SearchMiddleInitial*
    *Optional


    SBE API RESULTS

    "; echo htmlspecialchars($result['html']); echo '


    '; echo $result['html']; } ?>