PHP - Http Headers
Just a quick question. I'm using the Live HTTP Headers add-on for Firefox that display all the HTTP headers etc. I'm writing an article on it and want to include a screenshot of it in action. Are there any headers that I should hide from the reader for security reasons?
Thanks for any help. Similar TutorialsQuick question for you guys. I am collecting payment data for a product. Is it possible to send data from my form via http directly into another payment form via the post http headers? So say if i had all the details payment info and address info and i matched my form exactly to theirs. Is it possible to write a php script to send the data from my form directly to another websites form to make an order, say amazon or a big site like this? ?first_name=samuel&last_name=east&action=Submit Any Help? Thanks Hi Guys, This is my first post as part of the community. I am working on a personal project for myself and was trying to password protect some pages. Im newish to php and was wondering if HTTP AUTH headers work with MYSQL Databases for usernames and passwords. Any help or insight would be greatly appreciated! Thanks! Steve
Hello, I am a newbie regarding PHP and have done mostly only front-end web design for a couple of years and recently started querying DB's and displaying the data, but now this is a new project.
I've tested code snippets as the ones below, but fail to incorporate them in the bigger picture of what I'm trying to achieve. <?php // https://gist.github.com/magnetikonline/650e30e485c0f91f2f40 class DumpHTTPRequestToFile { public function execute($targetFile) { $data = sprintf( "%s %s %s\n\nHTTP headers:\n", $_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI'], $_SERVER['SERVER_PROTOCOL'] ); foreach ($this->getHeaderList() as $name => $value) { $data .= $name . ': ' . $value . "\n"; } $data .= "\nRequest body:\n"; file_put_contents( $targetFile, $data . file_get_contents('php://input') . "\n" ); echo("Done!\n\n"); } private function getHeaderList() { $headerList = []; foreach ($_SERVER as $name => $value) { if (preg_match('/^HTTP_/',$name)) { // convert HTTP_HEADER_NAME to Header-Name $name = strtr(substr($name,5),'_',' '); $name = ucwords(strtolower($name)); $name = strtr($name,' ','-'); // add to list $headerList[$name] = $value; } } return $headerList; } } (new DumpHTTPRequestToFile)->execute('./dumprequest.csv'); This snippet also seems to return the headers and their values but I don't know how to efficiently write and append it to a TXT or CSV, or preferably, directly into a MySQL database. <?php foreach (getallheaders() as $name => $value) { echo "$name: $value"; echo "<br>"; } ?>
Any help towards storing the header values of HTTP POST requests into a database would be greatly appreciated! Trying to run a simple program that, when submitted, stores the username and password as cookies. When clicking Submit, I get the error "HTTP Error 405 - The HTTP verb used to access this page is not allowed". If the username and password fields are left blank when submitting it's suppose to give a message to enter a username and password, but, I still get that error message. HTML form: Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Week 1 Project--Cookies</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <form action="cookie1.php" method="post"> <h2 align="center">Cookies</h2> <br /> <div> <p>Enter your username and password and click "Submit":</p><br /> <p>Username:<input type="text" name="username" size="20"></p> <p>Password:<input type="text" name="password" size="20"></p> </div> <br /> <div><input type="submit" name="submit" value="Submit" /></div> <br /> <div> <input type="reset" name="Reset" value="Start Over" /> </div> </form> </body> </html> PHP file: Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Cookie File</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <div> <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { setcookie('username', $_POST['username'], time() + 2592000); setcookie('password', $_POST['password'], time() + 2592000); } if(($_POST['username'] == "") || ($_POST['password'] == "")) { print "You must enter both a username and password. Press the Back button on your browser and try again."; } else if (isset($_COOKIE['username'])) { print "Welcome, " .$_COOKIE['username']; } ?> </div> </body> </html> How do I only redirect the page when index.php is present? My error: Code: [Select] Warning: Cannot modify header information - headers already sent by (output started at /www/zxq.net/w/e/b/webaskius/htdocs/index.php:7) in /www/zxq.net/w/e/b/webaskius/htdocs/functions.php on line 6 Now, I can't quite figure out why it's doing this. The section of code that is causing this problem is above any HTML tags, at the very beginning of the file. <?php include('functions.php'); ?> <link href="style.css" rel="stylesheet" type="TEXT/CSS"> <img src="logo.png" border="0"> <div id="maincontent"> As you can see, the functions that cause this error are at the VERY beginning of my file. This is where they are called within index.php: if(mysql_num_rows($query_verify_login) > 0) { create_cookie(10000, 'user', $username); redirect('index.php'); } else { echo 'Woops! You\'ve entered in the wrong username and password combination!'; } And finally, my functions: <?php //our cookie creator function function create_cookie($time, $name, $data) { setcookie($name, $data, time()+$time); } function redirect($url) { header('Location: '. $url .''); } function get_replies($id) { //set query to find posts that match our id $query_get_replies = mysql_query("SELECT * FROM replies WHERE to = {$id}"); return mysql_num_rows($query_get_replies); } ?> Okay, I've read all the rules for Headers...still can't it to execute properly. At the bottom is my code. I basically want to check the database, see if the user is already registered, and redirect as appropriate (there is no HTML on my page, no info sent to the browser). My server doesn't send any error messages. All I get are white screens. Now, if I do the headers_sent()...it tells me that it's sent right after the initial connection with the database. The ONLY way I can get it to redirect, is if I put <?php header("location:index.php?msg=3"); ?> at hte very top, but then I can't evalute...which doesn't help me much. Here is the code (obviously, I have more...but it's sending headers in these lines) <?php $connection = mysql_connect("localhost","####","#####"); if (!$connection){ echo mysql_errno().": ".mysql_error()."<br/>"; exit; } if(!mysql_select_db("prixaurora")){ echo("Database not found<br>"); } Hi I am getting the following php error that is on all my pages and it works fine on the other pages except index.php Code: [Select] <?php session_start(); include 'includes/conn_db.php'; if (isset($_POST['submit'])) { if (empty($_POST['userName'])) { $u = FALSE; $nouser = '<font color="red" size="2" face="arial">You forgot to enter your username!</font>'; } else { $u = $_POST['userName']; } if (empty($_POST['userPassword'])) { $p = FALSE; $nopass = '<font color="red" size="2" face="arial">You forgot to enter your password!</font>'; } else { $p = $_POST['userPassword']; } $errorMessage = $nouser . "<br>" . $nopass; if ($u && $p) { $query = "SELECT * from clients WHERE email = '$u' AND pword = '$p'"; $result = mysql_query($query, $conn); while ($row = mysql_fetch_assoc($result)){ if ($u == $row["email"] && $p == $row["pword"]) { $query_name = "SELECT * FROM clients WHERE email = '$u' AND pword = '$p'"; $result_name = @mysql_query ($query_name); while ($row_name = mysql_fetch_assoc($result_name)){ $client_id_out = $row_name['client_id']; $firstname_out = $row_name['firstname']; $lastname_out = $row_name['lastname']; // Create sessions $_SESSION['client_id'] = $client_id_out; $_SESSION['firstname'] = $firstname_out; $_SESSION['lastname'] = $lastname_out; ob_end_clean(); header ("Location: myaccount.php"); exit(); }} } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <link href="style.css" rel="stylesheet" type="text/css" /> <link href="layout.css" rel="stylesheet" type="text/css" /> <script src="js/jquery-1.3.2.min.js" type="text/javascript"></script> <script src="js/cufon-yui.js" type="text/javascript"></script> <script src="js/cufon-replace.js" type="text/javascript"></script> <script src="js/Futura_Bk_BT_400.font.js" type="text/javascript"></script> <script src="js/Futura_XBlk_BT_400.font.js" type="text/javascript"></script> <!--[if lt IE 7]> <script type="text/javascript" src="js/ie_png.js"></script> <script type="text/javascript"> ie_png.fix('.png'); </script> <![endif]--> </head> Thanks Lional hello, I'm using this code: <?php if (isset($_REQUEST['email'])) { $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; $code = $_REQUEST['code'] ; $from = $email; mail("email@email.com", "Winner request id: $name - code: $code", "From:" . $from); } $headers = "From:" . $from; header('Location: index.php?done'); ?> And I'm getting: Code: [Select] Warning: Cannot modify header information - headers already sent by (output started at /home/site/public_html/config.php:10) in /home/site/public_html/send.php on line 13 This worked before. Many thanks Hi all, It's probably something obvious, but perhaps someone could explain to me what is going on here... I spent a lot of time this afternoon trying to fix what seemed to be a very odd problem, which involved an image being chucked out like so: Code: [Select] <?php header("Content-Type: image/png"); echo file_get_contents("http://www.example.com/some_image.png"); ?> Except the image was coming out as corrupted, ultimately because I had some white space before this snippet (foolish, I know). The reason it took me so long to diagnose the problem was because I wasn't getting PHP errors (even though they were switched on). As far as the script was concerned, it seems I wasn't sending anything before attempting to modify the headers. After solving the problem, I put the following little bit of code together, trying to force a header error... And yet I get nothing. It all works, and I get redirected, when I'm sure I shouldn't be. I've run this on a default install of XAMPP, and a configured CentOS server, and the same thing happens on both. If anyone can explain to me what is going on, I would be most appreciative! There are some inline comments which should help clarify what I mean. Code: [Select] <?php error_reporting(E_ALL); ini_set("display_errors","1"); ?> <p>Hello! The very existence of this text should really have resulted in the headers being sent... Shouldn't it?</p> <p>So I'd expect to see a "Headers already sent" message... Shouldn't I?</p> <?php // Headers sent? echo "<p>"; echo "Headers "; if(!headers_sent()) { echo "not "; // This "not" does echo out. } echo "sent.</p>"; // This WILL start a session (or at least, won't throw an error) session_start(); // This redirect WILL work, and you will never see the above messages. header("Location: redirect.php"); // What?! ?> Thanks! Dave I have a form as a php include and it's giving me this error: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/altimusw/public_html/www.csmsolution.com/register.php:6) in /home/altimusw/public_html/www.csmsolution.com/core.php on line 17 Here is the main page that includes the php include: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>CSM Solution </title> <style type="text/css"> <!-- #Layer1 { position:absolute; left:100px; top:70px; width:800; height:62px; z-index:1; } .style1 { font-family: Arial, Helvetica, sans-serif; color: #535959; font-size: 12px; } --> </style> </head> <body> <div id="Layer1"> <table width="800" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="97"><img src="images/header.jpg" width="800" height="59" border="0" usemap="#Map" /><br /> <img src="images/navbar.jpg" width="800" height="38" border="0" usemap="#Map2" /> <map name="Map2" id="Map2"> <area shape="rect" coords="506,1,552,26" href="contact.php" /><area shape="rect" coords="459,1,502,26" href="form.php" /><area shape="rect" coords="396,-1,455,25" href="login.php" /> <area shape="rect" coords="357,0,393,26" href="index.php" /> </map> </td> </tr> <tr> <td><img src="images/welcome_img.jpg" width="131" height="21" /></td> </tr> <tr> <td><?php include("form.php"); ?></td> </tr> <tr> <td><img src="images/placeholderclouds_bottem.jpg" width="800" height="60" /></td> </tr> </table> </div> </body> </html> Here is the Core.php the error is referring to: <?php //CSM Solution Core. Rahul Parkar 2010 $_config = array(); $_config['db_type'] = "mysql"; $_config['db_server'] = "localhost"; $_config['db_username'] = "altimusw_csm"; $_config['db_password'] = ']17=rXh7tJ0~'; $_config['db_database'] = "altimusw_csm"; $_config['db_tbl_prefix'] = ''; $_config['user_table'] = "customers"; $_config['user_username'] = "username"; $_config['user_password'] = "password"; $_config['user_active'] = "approved"; $_config['user_role1'] = "prirole"; $_config['user_role2'] = "secrole"; $_config['pass_hash_func'] = "SHA1"; session_start(); function fetch_row($query) { build_connection($db); sql_exec($db, $query, $result); sql_fetchone($result, $row); finish_connection($db); return $row; } function build_connection(&$db) { global $_config; if ($_config['db_type'] == "mysql") { $db = mysql_connect($_config['db_server'], $_config['db_username'], $_config['db_password']) or die(mysql_error()); mysql_select_db($_config['db_database'], $db) or die(mysql_error()); } } function sql_exec(&$db, $query, &$result) { global $_config; if ($_config['db_type'] == "mysql") $result = mysql_query($query, $db) or die(mysql_error() . "/$query"); } function sql_fetchone(&$result, &$row) { global $_config; if ($_config['db_type'] == "mysql") { $row = mysql_fetch_assoc($result); @mysql_free_result($result); } } function sql_do(&$db, $query) { global $_config; sql_exec($db, $query, $noclue); finish_connection($db); } function finish_result(&$result) { global $_config; if ($_config['db_type'] == "mysql") @mysql_free_result($result); } function finish_connection(&$db) { global $_config; if ($_config['db_type'] == 'mysql') mysql_close($db); } function check_auth($username, $password) { global $_config; $row = fetch_row("SELECT `" . $_config['user_active'] . "`, `" . $_config['user_password'] . "`, " . $_config['pass_hash_func'] . "('" . $password . "') AS `passcheck`, `fname`, `lname` FROM `" . $_config['user_table'] . "` WHERE `" . $_config['user_username'] . "`='" . $username . "' LIMIT 1"); if (!$row[$_config['user_active']]) { return -1; } else { if ($row[$_config['user_active']] != 1) { return -2; } else if ($row[$_config['user_password']] == $row['passcheck']) { $_SESSION['username'] = $username; $_SESSION['fname'] = $row['fname']; $_SESSION['lname'] = $row['lname']; return 1; } else { return -1; } } } function load_access() { global $_config; if ($_SESSION['username']) { $row = fetch_row("SELECT `" . $_config['user_role1'] . "` FROM `" . $_config['user_table'] . "` WHERE `" . $_config['user_username'] . "`='" . $_SESSION['username'] . "' LIMIT 1"); $role1 = $row[$_config['user_role1']]; $_SESSION['role1'] = $role1; } else { return -1; } } function has_level() { for ($i = 0; $i < func_num_args(); $i++) { if (func_get_arg($i) == $_SESSION['role1']) { return 1; } } return 0; } ?> I am trying to do a page redirect using the header() function.
I am aware that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP.
and also that reading code with include, or require, functions, or another file access function, can create spaces or empty lines that are output before header() is called. thus causing a redirect failure.
I have therefore used this output control function (ob_start(); ob_implicit_flush() right at the top of my page.
I am then creating the redirect like this as part of my login() function:
if($user_role == ADMIN_LEVEL || $user_role == EDITOR_LEVEL) { if (!headers_sent($filename, $linenum)) { return header("Location:http://mysite.com/dashboard.php"); exit; } else { echo "Headers already sent in $filename on line $linenum\n" . "Cannot redirect\n"; exit; } }Unfortunately I am still getting this error: Headers already sent in /home/steveoje/public_html/login.php on line 1 Cannot redirectAnd this is what I have at the top of the login.php page: <?php ob_start(); ob_implicit_flush(); require_once 'includes/config.php'; if(isset($_POST['submit'])) { login($_POST['username'], $_POST['password']); } require_once "includes/header.inc.php" ?> //other html contentSo why would the redirect fail in this instance? Thanks. Edited by terungwa, 28 September 2014 - 05:28 AM. Simple question. How do I redirect the header location on a session page. I thought I could go a different direction, but now I'm back to this one. I tried just adding header("Location: newpage.php") at the end of a query insert, but it gave me the warning that it can't modify the head. But I need the page to redirect after the query is done. Thoughts? Hi I have coded a form, and dependant upon the result I would like to re-direct to a different page. The problem is I am getting the "headers already sent" message..Is there a way around this, I can't use JS re-direction because of accessibility. E.G: <?php //Do stuff with form data if($result = y){ header(Location: "mysite.php/thankyou.php"); } else{ header(Location: "mysite.php/error.php"); } ?> In-fact whilst typing this I have an idea, why not do all of this at the top of the page before headers are sent? I'll go ahead and try it now, in the meantime if anybody knows how or if headers can be sent after output please let me know thanks. I'm adding a login page to my website. When I go to the login page, and try to login, I keep getting the error "Warning: Cannot modify header information - headers already sent by (output started at C:\Users\me\Desktop\xampp\htdocs\site\login.php:7) in C:\Users\me\Desktop\xampp\htdocs\site\login.php on line 38" and I don't know why. I've looked into it, and from what I can tell its something to do with white spaces, but I cant find them. <?php include "./dbconnect.php"; ?> <?php forum_connect(); ?> <?php if(isset($_COOKIE['ID_forum'])) { $username = $_COOKIE['ID_forum']; $pass = $_COOKIE['Key_forum']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { } else { header("Location: main.php"); } } } if (isset($_POST['submit'])) { if(!$_POST['username'] | !$_POST['pass']) { die(' <h2> You did not fill in all of the fields</h2> <p<a href="login.php">Return to login page</a> '); } if (!get_magic_quotes_gpc()) { $_POST['email'] = addslashes($_POST['email']); } $check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error()); $check2 = mysql_num_rows($check); if ($check2 == 0) { die(' <h2> That user does not exist in our database.<br/> </h2> <p<a href="login.php">Return to login page</a> '); } while($info = mysql_fetch_array( $check )) { $_POST['pass'] = stripslashes($_POST['pass']); $info['password'] = stripslashes($info['password']); $_POST['pass'] = md5($_POST['pass']); if ($_POST['pass'] != $info['password']) { die(' <h2> Incorrect password, please try again</h2> <p<a href="login.php">Return to login page</a> '); } else { $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(ID_forum, $_POST['username'], $hour); setcookie(Key_forum, $_POST['pass'], $hour); header("Location: main.php"); } } } else { ?> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table border="0"> <tr><td colspan=2><h1>Login</h1></td></tr> <tr><td><h2>Username:</h2></td><td> <input type="text" name="username" maxlength="40"> </td></tr> <tr><td><h2>Password:</h2></td><td> <input type="password" name="pass" maxlength="50"> </h2> </td></tr> <tr><td colspan="2" align="right"> <input type="submit" name="submit" value="Login"> </td></tr> </table> </form> <?php } ?> Any help would be great Thanks Hi, I have a php email form and in the headers, I just want to add a 2nd email that the form will send to. I can only get the form to be sent to the first email? This is the code I currently have: $headers .= 'From: The Group <me@aol.com>' . "\r\n"; $headers .= 'CC: me2@aol.com'. "\r\n"; Is my code off for the CC email? Thanks for the help! Hi ! I am currently trying to develop a PHP application in which my server downloads a file and the user can do the same almost simultaneously. I already think about the problem "If the user downloads fastly than the server...", but it's not a problem at this moment. To do so, I used the header and readfile functions of php. Here is my code : Code: [Select] header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.$data['name'].'";'); header('Content-Transfer-Encoding: binary'); header('Content-Length: '.$data['size']); readfile($remoteFile); I must to use the Content-length header to set the proper size of the file and not the size that is downloaded when the user clicks on the link. However, after some seconds or minutes, download is stopped and I need to restart... If you think about a solution, even if it didn't use the header(); function, please tell me. Thank you in advance... ok i read the header part but i sure i did it rite but its givong me those erros Code: [Select] <?php session_start(); $username = $_SESSION['username']; ?> <?php require "scripts/connect.php"; if($_POST['submitbtn']){ $body = mysql_real_escape_string($_POST['area1']); if($body){ $query = mysql_query("UPDATE history SET body ='$body'"); echo $msg = "UPDATED GOOD"; header('location: http://www.rbrhslsp.org/rbrhsadmins/edithistory'); }else $msg = "Please fill in the body"; } mysql_close(); ?> <?php require "scripts/connect.php"; $query = mysql_query("SELECT * FROM history"); $rows = mysql_fetch_assoc($query); $body = stripslashes($rows['body']); mysql_close(); ?> <?php require "header.php"; ?> <?php if ($username){?> <div id="leftContent"> <h4> Your page </h4> <?php echo $msg;?> <form action='edithistory' method='post'> <textarea style="height: 100px; width:490px;" name="area1" cols="58"><?php echo $body;?></textarea> <input type='submit' name='submitbtn' value='Submit' /> </form> </div> Hi everyone, thanks for reading. I have live HTTP headers installed on Firefox, hopefully some of you will be familiar with this addon. I would like to make a php script that is able to do what live http headers does, that is, I'd like to be able to give the script a URL and it will return all the headers. I know how to use CURLOPT_HEADER and CURLOPT_RETURNTRANSFER but this doesn't quite do what I'm looking for. For example if I go to : https://adwords.google.com/o/Targeting/Explorer?__c=1000000000&__u=1000000000&ideaRequestType=KEYWORD_STATS#search.none with Live HTTP Headers switched on I get the following data under the 'generators' tab GET /o/Targeting/Explorer?__c=1000000000&__u=1000000000&ideaRequestType=KEYWORD_STATS GET /cues/cues.js GET /ga.js GET /cues/cb?__u=1000000000&__c=1000000000&l=en_US&v=5E5BE5A3D9AD806BA7FF2C9FE2E15DF9&a=1000000000 GET /cues/metrics/?requestType=external&startTime=1287073462287&browserStartTime=1287073471028&browserEndTime=1287073472156 GET /cues/metrics/?requestType=notabs&startTime=1287073462287&browserStartTime=1287073471028&browserEndTime=1287073472162 GET /o/Targeting/clear.cache.gif GET /__utm.gif?utmwv=4.8.6&utmn=606563096&utmhn=adwords.google.com&utmcs=UTF-8&utmsr=1280x1024&utmsc=24-bit&utmul=en-gb&utmje=1&utmfl=10.1%20r85&utmdt=Google%20AdWords%3A%20Traffic%20Estimator&utmhid=1700273830&utmr=-&utmp=%2FAnonymous%2FTargetingExplorer%2FKeywordStats%3Fcontext%3DHistoryChange%26__c%3D1000000000%26__u%3D1000000000%26ideaRequestType%3DKEYWORD_STATS&utmac=UA-3418223-1&utmcc=__utma%3D229779660.119716289.1279381615.1286975241.1287071773.41%3B%2B__utmz%3D229779660.1279381615.1.1.utmcsr%3D(direct)%7Cutmccn%3D(direct)%7Cutmcmd%3D(none)%3B&utmu=q GET /o/Targeting/F098CA184E661C697D29595B67C57BAA.cache.png GET /favicon.ico POST /o/Targeting/captcha?__u=1000000000&__c=1000000000&challengedService=/o/Targeting/g 6|1|4|https://adwords.google.com/o/Targeting/|02990CDDCF521142AE1B373ED2008D94|_|getToken|1|2|3|4|0| GET /o/Targeting/captchaData?token=AJtyWwbzrehZWrT8puwruvcvjxCHnRJWKqWvpWfw54W2AjmF2cAlFpYLcL13KE0hi7retjZclcFHqnd8yMC0vDfP4tRNXISZ1QfbdLBK_WVW1wqlzqrR2ouSBgclxUiU0RiHUXHWy1VrIlo5oq3xNeemD-dZHQr0ed1s6p-dBF9mvyvkct1BifkXPAD___W32qxemYPbi6qvgpec3-rgsesGVUoYPglxzg&type=IMAGE GET /favicon.ico However my current CURL script only returns the following HTTP/1.1 200 OK Cache-Control: no-cache, no-store, max-age=0, must-revalidate Pragma: no-cache Expires: Fri, 01 Jan 1990 00:00:00 GMT Date: Thu, 14 Oct 2010 17:05:12 GMT Content-Type: text/html; charset=UTF-8 X-Invoke-Duration: 8 X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block Server: GSE Transfer-Encoding: chunked This is my script so far <?php $url="https://adwords.google.com/o/Targeting/Explorer?__c=1000000000&__u=1000000000&ideaRequestType=KEYWORD_STATS#search.none"; $useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"; //next open a new CURL session $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_USERAGENT, $useragent); curl_setopt ($ch, CURLOPT_HEADER, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_FRESH_CONNECT, 0); curl_setopt ($ch, CURLOPT_CAINFO, dirname(__FILE__)."/cacert.pem"); $source=curl_exec($ch); //the source code is now stored in $source, lets close the curl session curl_close($ch); echo $source; ?> |