PHP - Using Php To Post To A To A Another Page?
lets say I have two pages:
Code: [Select] one.php Code: [Select] two.php Now with that in mind, is there a way for page one.phpto automatically post values to page two.php viathe $_POST variable? Similar TutorialsSome code from my pages ,
Page1 ( Redirecting page )
<html> <title>login_redirect.</title> body> <form name="redirect" action="http://mysite/page2.php" method="post"> <input type="hidden" name="mac" value="$(mac)"> </form> <script language="JavaScript"> <!-- document.redirect.submit(); //--> </script> </body> </html>Page 2 ( select product ) <?php session_start(); ini_set('display_errors',1); error_reporting(E_ALL); include '../lib/config.php'; include '../lib/opendb.php'; // get user mac adres from redirect post page1 $_SESSION['macid'] = $_POST['mac']; // set $macid for other use ( maybe not needed, am learning ) $macid = $_SESSION['macid']; // echo $macid does show mac adress, so variable is not empty here if (!empty($_POST["submit"])) { $product_choice = $_POST['accounttype']; $query= "SELECT AccountIndex, AccountCost, AccountName FROM AccountTypes WHERE AccountIndex='$product_choice'"; $result = mysql_query($query) or die('Query failed. ' . mysql_error()); while($row = mysql_fetch_array($result)) { $_SESSION['AccountIndex'] = $row['AccountIndex']; $_SESSION['AccountCost'] = $row['AccountCost']; $_SESSION['AccountName'] = $row['AccountName']; } header('Location: page3.php'); } // did leave out the other/html/form stuff herePage 3 ( show Session variables ) <?php ini_set('display_errors',1); error_reporting(E_ALL); session_start(); print_r($_SESSION); ?>Now, on page 3 i do see the right session varables, only the "macid" is empty. why ? Hi I need some help. I wanted to create a start and end event date using date picker and also after selecting the start and end date, it will calculate the number of days (duration). I have found the date picker which can do what I want but I need help to post the duration to another php page when user click on submit. Can anyone help me. You might want to refer to my attach PHP page and here is the link to the datepicker, http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerStartEnd.html Thanks Ben Chew [attachment deleted by admin] I want my form to POST to the same page, but not have the 'document expired' problem when sessions are being used somewhere in the script (when I hit press the back button in the browser). I know this can be avoided by posting to a different PHP page, and then use a header(location) to redirect, but I ideally want to keep it on the same page as I use some of the variables produced from within the processing section.
Please excuse the crude examples,
This works:
session_start(); /*HEADER*/ if(isset($_POST['test']){ //do some validation $validated= true; if($validated){ //process the form $_SESSION['notification'] = 'form submitted successfully'; header('location: samepage.php'); exit; } else{ $_SESSION['notification'] = 'there was an error'; header('location: samepage.php'); exit; } } /*BODY*/ if(!isset($_SESSION['notification'])){ //show the form.. posts 'test' to current page } else { echo $_SESSION['notification']; unset($_SESSION['notification']); }And this method shows the document expired when the page is refreshed... session_start(); /*HEADER*/ if(isset($_POST['test']){ //do some validation $validated= true; if($validated){ //process the form $success = true; } else{ $success = false; } } /*BODY*/ if(!isset($success)){ //show the form.. posts 'test' to current page } else if($success){ echo 'form submitted successfully'; } else{ echo 'there was an error'; }I've read that I can edit the php.ini file to allow caching, which should solve the issue for example 2. Is example 1 the correct way to be doing this? It's been pointed out that I shouldn't be using 'exit' so much so I'm trying to explore the correct methods Edited by paddy_fields, 31 July 2014 - 07:04 AM. When a person visits my site I would like for the form on the page to submit and reload with the predetermined search criteria. Is this possible? So for example...if you visited my site as soon as you entered the from would submit and display Google search results for "php freaks" I tried header("location: mysite.com?q=php+freaks"); but that is a continuous loop. -Any thoughts I currently have a php form that asks for first name, last name and email address then when they click submit it sends me an email with this information. I also have a javascript that pops up a window saying their message was sent with an ok button that redirects them back to the main page. I'd like to change this to redirect them to a new php page with a certificate with their name on it taken from the previous php form (but still email me the information). My form action currently points back to the same php page for verification of information (like valid email address, etc.) so I can't point that to a new page. Is there any way to do this? The variables I have for the first name and last name are just $firstname and $lastname. Hello I have this code that searches multiple tables. running this query in the phpmyadmin page works fine and gives correct results. I echo-ed the $kw and noticed that it is lost (empty) when I click on Next (when moving to the second page or so..) How do I save the $kw for all search results? Thank you so much $kw = trim($_POST['keyword']); $kw = mysql_real_escape_string($kw); //Nomber of rows to display per page $page_rows=20; //This checks to see if there is a page number. If not, it will set it to page 1 if (!(isset($pagenum))) { $pagenum = 1; } echo "$kw of $pagenum"; //Count we count the number of results $data = mysql_query(" SELECT `id`,`title`, `body`, 'condoms_en' as REF FROM `condoms_en` where `title` like '%$kw%' OR `body` like '%$kw%' UNION SELECT `id`,`title`, `body`, 'discr_en' as REF FROM `discr_en` where `title` like '%$kw%' OR `body` like '%$kw%' UNION SELECT `id`,`title`, `body`, 'diseases_en' as REF FROM `diseases_en` where `title` like '%$kw%' OR `body` like '%$kw%' UNION SELECT `id`,`title`, `body`, 'express_en' as REF FROM `express_en` where `title` like '%$kw%' OR `body` like '%$kw%' ") or die(mysql_error()); $rows = mysql_num_rows($data); if ($rows ==1 || $rows > 1) { //echo "Number of rows $rows <br/>"; //This tells us the page number of our last page $last = ceil($rows/$page_rows); //this makes sure the page number isn't below one, or more than our maximum pages if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //echo "<h4>".$pagenum."-20 of ".$total."results</h4> <br />"; // This shows the user what page they are on, and the total number of pages echo " ===> Page $pagenum of $last <br/><br/>"; //This sets the range to display in our query $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; //This is your query again, the same one... the only difference is we add $max into it $data_p = mysql_query(" SELECT `id`,`title`, `body`, 'condoms_en' as REF FROM `condoms_en` where `title` like '%$kw%' OR `body` like '%$kw%' UNION SELECT `id`,`title`, `body`, 'discr_en' as REF FROM `discr_en` where `title` like '%$kw%' OR `body` like '%$kw%' UNION SELECT `id`,`title`, `body`, 'diseases_en' as REF FROM `diseases_en` where `title` like '%$kw%' OR `body` like '%$kw%' UNION SELECT `id`,`title`, `body`, 'express_en' as REF FROM `express_en` where `title` like '%$kw%' OR `body` like '%$kw%' $max") or die(mysql_error()); //This is where you display your query results while($info = mysql_fetch_array( $data_p )) { print $info['title']; //print $info['REF']; echo "<br>"; } echo "<p><br/>"; // First we check if we are on page one. If we are then we don't need a link to the previous page //or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page. if ($pagenum == 1) { } else { echo " <a style=\"color: #FF0000\" href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a style=\"color: #FF0000\" href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> "; } //just a spacer echo " ---- "; //This does the same as above, only checking if we are on the last page, and then generating the Next and Last links if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a style=\"color: #FF0000\" href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> "; echo " "; echo " <a style=\"color: #FF0000\" href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> "; } } //results was found else { echo "No results FOUND"; } Form.php Code: [Select] <html> <head> <script type="text/javascript"> function addsmiley(code) { var pretext = document.smile.message.value; this.code = code; document.smile.message.value = pretext + code; } function a() { var x = document.smile.message.value; if(x=="") { alert("Please insert an message!"); return false; } } </script> <style type="text/css"> body{ background-color: #d8da3d } </style> </head> <body> <form name="smile" method="post" action="registration.php" onSubmit="return a()" > Your message:<br><textarea name='message' cols='40' rows='2'></textarea><br> <img src="smile.gif" alt=":)" onClick="addsmiley(':)')" style="cursor:pointer;border:0" /> <img src="blush.gif" alt=":)" onClick="addsmiley('*blush*')" style="cursor:pointer;border:0" /> <input type='submit' name='submit' value='Set Name' class='biasa' ></form> <br> <br> </body> </html> Registration.php Code: [Select] <?php $m=$_POST['message']; echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('$m')</SCRIPT>"); ?> <html> <head> <script type="text/javascript"> function a() { var x = document.register.username.value; var y = document.register.pass.value; var z = document.register.pass2.value; if(x==""&& y==""&& z=="") { alert("Please insert all message!"); return false; } if(x=="") { alert("Please insert an username!"); return false; } if(y=="") { alert("Please insert an password!"); return false; } if(z=="") { alert("Please insert an password2!"); return false; } if (y!=z) { alert("Your passwords did not match"); return false; } } </script> </head> <body> <form name="register" method="post" action="login.php" onsubmit="return a()"> <table border='0'> <input type="text" name="<?php $m?>"> <tr><td>Username:</td><td><input type="text"name="username" maxlength="60"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" maxlength="10"></td></tr> <tr><td>Confirm Password:</td><td><input type="password" name="pass2" maxlength="10"></td></tr> <tr><th colspan=2><input type="submit" name="sub" value="Register"></th></tr> </table> </form> </body> </html> Your message:<br><textarea name='message' cols='40' rows='2'></textarea><br> This i took from form.php and when it passed to registration.php when im called it in javascript <?php $m=$_POST['message']; echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('$m')</SCRIPT>"); it can show the message im put in form.php but when im put into input text that is <input type="text" name="<?php $m?>"> but the input text is blank not put the message im post in form php may i know which is the error Hi, Can any one help me wit the pagination in android mobile App Pls find the attached file for full code As per the below coe it displays only 40 posts but i have around 500 posts. I can increse function add_query_vars($public_query_vars) { $public_query_vars[] = $this->namespace.'_p'; return $public_query_vars; } $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'category__in' => $categories, ); if ($wp->query_vars[$this->namespace.'_p'] == 1){ $args['posts_per_page'] = 10; $args['offset'] = 0; }else{ $args['posts_per_page'] = 40; $args['offset'] = 10; } $posts = get_posts($args); I have tried but i am getting only 210 posts.only if i increse the post_per_page more than 70 in mobile android app it shows loding $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'category__in' => $categories ); if ($wp->query_vars[$this->namespace.'_p'] == 1){ $args['posts_per_page'] = 70; $args['offset'] = 0; } if ($wp->query_vars[$this->namespace.'_p'] == 2){ $args['posts_per_page'] = 140; $args['offset'] = 70; } if ($wp->query_vars[$this->namespace.'_p'] == 3){ $args['posts_per_page'] = 210; $args['offset'] = 140; } $posts = get_posts($args); Attached Files wp-app-maker.php 49.23KB 1 downloads Well i have a session['rmanr'] a have set after a submit containing the date and unique id.
I have to be able to do multiple submits on that same form but if they submit multiple times the same rmanr have to be used...
I tried the following:
$date = date("Y-m-d"); $datestrip = str_replace("-", "", $date); $lastdetid = $dbh->lastInsertId(); if(!isset($_SESSION['rmamr'])){ $rmanr = $datestrip; $rmanr .= $lastdetid; $_SESSION['rmanr'] = $rmanr; } else { $rmanr = $_SESSION['rmanr']; } $uprmastmt = $dbh->prepare("UPDATE rma SET r_nr = '$rmanr' WHERE r_id = ?"); $uprmastmt->bindParam(1, $lastid); $uprmastmt->execute();But i keep getting a new rmanr every time i submit... Could it be that my form submit reset my SESSION? what I am trying to accomplish is for the user to select the state they wish, hit submit. At this point another form should show asking which county based on the state they picked, then hit search. At this point, I'm having an issue having the state variable being passed to the 2nd form also having the state they selected stay selected. <?php $default = "Step 1. Pick Your State"; $select = "<option name='statebox'>$default</option>"; echo "<br/><form method='POST' action=".$_SERVER['PHP_SELF']." >"; echo "<select name='search'>"; echo "$select"; /////////////////////////////////////////////////////////////// //Connect to the database include_once 'phpforms/connect.php'; $sql = mysql_query("SELECT * FROM states"); while($row = mysql_fetch_array($sql)){ $state = $row['states']; echo "<option name='statebox'>$state</option>"; }//End While /////////////////////////////////////////////////////////////// echo "</select>"; echo "<input align='left' type='submit' name='stateboxbutton' value='Ok'> "; echo "</form>"; echo "</td>"; echo "<td>"; if(isset($_POST['stateboxbutton'])){ $statesearch = $_POST['statebox']; $selected = $_POST['statebox']; $select = "<option name='statebox'>$selected</option>"; echo "<br/><form action='../search-results.php' method='POST'>"; echo "<select name='search'>"; echo "<option name='default'>Step 2. Pick Your County</option>"; /////////////////////////////////////////////////////////////// //Connect to the database include_once 'phpforms/connect.php'; $sql = mysql_query("SELECT * FROM counties WHERE state LIKE '$statesearch'"); while($row = mysql_fetch_array($sql)){ $co = $row['counties']; echo "<option name='county'>$co</option>"; }//End While /////////////////////////////////////////////////////////////// echo "</select>"; echo "<input align='left' type='submit' name='button' value='Search'> "; echo "</form>"; }else{ }//End Else ?> Greetings... I have been staring at my whiteboard pondering a new architecture for processing data in an application. New for me anyways. I want to create a more centralized and modular method of handling data. For ease of explanation I will put it into the context of a login system which is where I first started thinking about this. I know there are a lot of login systems out there but I wanted to create one from scratch which utilizes PDO although that specific thing is not germane to my main question. Here we go... Lets say that for my Registration, Login and Forgot Password pages the forms on each page were directed to "Process.php" The idea is that process.php will provide the centralized platform to deal with data, acting as a choke point in the application making it easier to secure. This will also provide the means to quickly develop new parts of an application knowing that my methods of dealing with data area already well defined and secure. There is one hole in the idea that I can see though. If the user data being submitted to the process.php page does not meet the security requirements then the user must be sent back to the previous page. I dont' want to lose the data they have already entered into the forms. ie. I want to have it appear in the form fields... makes sense right. Now here comes my question... is there a way to pass POST data when using header("location: http://mySite/previousPage.php") It seems from my experiments that the data is lost. I do not use header(); often. In previous designs I have usually created each part of a login system as seperate and self contained entities apart from using a common db object. I know there are other ways around this, using session data for instance but this idea has been eating away at me for a little while and I feel its time to ask around for some advice. It has become a matter of curiosity. I have found some info on sending POST data using header but it did not seem to meet the requirement that the user and the POST data be sent to another page synchronously. At first I thought that maybe I would just do validation on the frontend / view pages (not to be taken as clientside) and if it was valid, then submit it to process.php, validate it again the let it be handled appropriately to its particular end but then I run into the same problem plus there is the extra overhead of validating the data twice. I guess thats it for now. Sorry if that was a little long-winded... its part of my process, helps me to better understand what I really want to know. Using header() on a receiving page from a form page... the redirecting header() with POST data, sending the user to a new/previous page. Possible? hi all, mine http call : <script type="text/javascript"> var leadidarray =new Array(); leadidarray[1] = 100; leadidarray[2] = 200; leadidarray[3] = 300; leadidarray[4] = 400; leadidarray[5] = 500; var url = 'test.php?query=test&leadarray='+leadidarray; $.getJSON(url,function(data){}); <script> Now on the processing page i am getting $row = $_GET[leadarray] ; var_dump($_GET[leadarray]); or print_r( $_GET[leadarray] ); gives me values 100,200,300,400,500 but i want all that separate variables or all values in array so i can compare with another array, how can i do that? Hi everyone, I am making a screen scraper in php which scrapes the usernames from forum posts and stores them in an SQL database. I need some help with part of the preg_match code if possible please? The code and also the pseudo code I have so far is:(the pseudocode I am having trouble with but will try to solve my self if possible). Edit: sorry, editted the page as was confusing to read. Please ask for clarificaiton if there is anything I have failed to explain properly. thank you. //I will be placing the following php in the confirmation page people see after making a new post, so for this example lets say the referrer header says: http://www.mysite.com/showthread.php?tid=1' Code: [Select] $threadurl=$_SERVER['HTTP_REFERER']; // scrape the page Code: [Select] $content = file_get_contents($threadurl); // find the pattern in source which makes it easy to find the username- the only things that change are the uid and the color Code: [Select] if (preg_match("/\b uid=792"><span style="color:#ffcc00">fapafap</span></a>\b /i", $content)) { //extract username from this string search Don't know! //copy the username (in this case 'fapafap') to the database along with the referral ID Code: [Select] $query_insert="INSERT INTO newpostersdatabase(username,referrerurl) VALUES('$username','$threadurl')" ; $result=mysql_query ( $query_insert); if(!$result){ die(mysql_error()); } Thank you so much for any guidance, I know that I have totally messed up with the string search also but my brain is too small it seems! This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=346243.0 Hi all, I am new here and I really thank God that I found this forum! I have read the materials here on working with cURL on javascript-form-submission pages. However, I can't to get my script to work. Can anybody here please help me out or drop me a hint on where to correct my script? ==Situation== My company utilizes http://www.myfax.com/free/ to send our company faxes. My task is to write a code that would submit files for faxes electronically. Note: The site also requires e-mail confirmation but I haven't get to that stage yet. I have run tests on submitting fax requests both by code and manually through the site, and have confirmed that the code doesn't work on the submission level because I managed to receive confirmation e-mails for manual submissions. Also, I tried my script with different staff email addresses because I figured out that it blocks only the same e-mail address from sending more than 2 faxes a day. Code: (php) [Select] <?php //target page url $strPage_url = 'www.myfax.com/free/'; //create array of data to be posted $arrPost_data = array ( 'ctl00$MainSection$tbRecipientName' => 'I am recipient', //max length = 50 'ctl00$MainSection$tbRecipientCompany' => 'I am recipient company', //max length = 50 'ctl00$MainSection$tbRecipientFaxNumber' => '+1 (206) 202-8273', //recipient fax 'ctl00$MainSection$ddlRecipientCountry' => html_entity_decode ('{"c":{"i":"2","n":"United States","t":"1","s":"US"},"m":{"i":"1","v":"+1 (###) ###-####","d":"","f":"","c":"","r":""}}'), 'ctl00$MainSection$tbSenderName' => 'I am sender', //max length = 50 'ctl00$MainSection$tbSenderCompany' => 'I am sender company', //max length = 50 'ctl00$MainSection$tbSenderEmailAddress' => 'abc@example.com', //email 'ctl00$MainSection$nbAntiSpam$nbAntiSpam_NoBotExtender_ClientState' => '-150', //number drawn from inspecting the packages sent by manual form submission 'ctl00$MainSection$fileUpload' => '@/files/file.pdf', //file 'ctl00$MainSection$tbMessage' => 'hello world', //message '__EVENTTARGET' => '', '__EVENTARGUMENT' => '', '__VIEWSTATEENCRYPTED' => '' ); //visit the page and get cookies $curl_connection = curl_init ($strPage_url); curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 0); curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($curl_connection, CURLOPT_REFERER, "http://www.myfax.com/free/"); curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($curl_connection, CURLOPT_COOKIEJAR, 'CURLCOOKIE'); $strGet_page_contents = curl_exec ($curl_connection); curl_close ($curl_connection); //get page to retrieve view state and event validation if ( preg_match ( '/"__VIEWSTATE"[\s]+?value="([\s\S]+?)"/' , $strGet_page_contents , $arrView_state ) ) { $strView_state = $arrView_state[1]; $arrPost_data['__VIEWSTATE'] = $strView_state; } if ( preg_match ( '/"__EVENTVALIDATION"[\s]+?value="([\s\S]+?)"/' , $strGet_page_contents , $arrEvent_validation ) ) { $strEvent_validation = $arrEvent_validation[1]; $arrPost_data['__EVENTVALIDATION'] = $strEvent_validation; } if ( preg_match ( '/id="ctl00_MainSection_nbAntiSpam_nbAntiSpam_NoBotExtender_ClientState" value="([\s\S]+?)"/' , $strGet_page_contents , $arrAnti_spam ) ) { $strAnti_spam = $arrAnti_spam[1]; $arrPost_data['ctl00$MainSection$nbAntiSpam$nbAntiSpam_NoBotExtender_ClientState'] = $strAnti_spam; } //traverse array and prepare data for posting (key1=value1) foreach ( $arrPost_data as $key => $value) { $arrPost_items[] = $key . '=' . $value; } //create the final string to be posted using implode() $strPost_string = implode ('&', $arrPost_items); //create cURL connection $curl_connection = curl_init($strPage_url); //set options curl_setopt ($curl_connection, CURLOPT_POST, 1); curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 0); curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($curl_connection, CURLOPT_REFERER, "http://www.myfax.com/free/"); curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1); //set cookie curl_setopt ($curl_connection, CURLOPT_COOKIEFILE, 'CURLCOOKIE'); unlink ( 'CURLCOOKIE' ); curl_setopt($curl_connection, CURLOPT_COOKIE, session_name() . '=' . session_id()); //set header $arrHeaders = array ( 'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8' ); curl_setopt($curl_connection, CURLOPT_HTTPHEADER, $arrHeaders ); //set data to be posted curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $strPost_string); //perform our request $strResult = curl_exec($curl_connection); //show information regarding the request - for debugging echo "<pre>"; print_r(curl_getinfo($curl_connection)); echo curl_errno($curl_connection) . '-' . curl_error($curl_connection); echo "<hr>"; var_dump ($arrPost_items); echo "</pre>"; //close the connection curl_close($curl_connection); ?> Hi there, I wrote a pretty simple html form that inputs data into my database. I've included a truncated version of it, There are a lot more fields. Basically when i hit the submit it processes input.php but after its been successful the page is still at input.php in the browser Is there anyway to take the page back to the page i was using to input data Code: [Select] <form action="insert.php" method="post"> <p>Adornment Name: <br> <input type="text" name="name"> <br> <br> Quality: <br> <select name="quality"> <option value="Other">Other Not Listed</option> <option value="Superior">Superior</option> <option value="Greater">Greater</option> <option value="Lesser">Lesser</option> <option value="Raid">Raid</option> <option value="Faction">Faction</option> </select> </form> Code: [Select] include 'db_connect.php'; $sql="INSERT INTO $db_table (name, quality) VALUES ( '$_POST[name]', '$_POST[quality]')"; if (!mysql_query($sql,$db)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($db) ?> This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=343888.0 Hi there, Any help is greatly appreciated. I've commented out the code giving me trouble. Error = <br /> <b>Warning</b>: curl_setopt(): supplied argument is not a valid cURL handle resource in <b>/###.php</b> on line <b>34</b><br /> <br /> <b>Warning</b>: curl_setopt(): supplied argument is not a valid cURL handle resource in <b>/###.php</b> on line <b>35</b><br /> <?php $ch = curl_init(); $timeout = 30; $userAgent = $_SERVER['HTTP_USER_AGENT']; if ($_REQUEST['update']) { curl_setopt($ch, CURLOPT_URL, $_REQUEST['url']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_USERPWD, $_REQUEST['username'] . ':' . $_REQUEST['password']); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); //curl_setopt($c, CURLOPT_POST, true); //curl_setopt($c, CURLOPT_POSTFIELDS, $_REQUEST['update']); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); $response = curl_exec($ch); if (curl_errno($ch)) { echo curl_error($ch); } else { curl_close($ch); echo $response; } } Hi guys, I know that you can open web page with $handle = fopen("http://www.example.com/", "r"); but i am wondering is there a way to pass POST vars when doing so, or there is another method that can that like you do it with ajax. I have mvc application that i want to test. I am using CodeIgniter framework so i want to call my controllers with POST values. Every controller method returns data holder object that holds the data of operation whether is successful or not. Also every method inside controller can be called with parameter input or with post input. If you omit the parameters when calling controller method than he will try to load that parameters from post and that is why i want to pass POST vars with php when calling controller for example i want to call: fopen("http://localhost/MyAppFolder/index.php/controller/method"); but i want to pass it some POST vars if that is possible Thanks. Alright, so I play a browser game called Politics and War. I run an alliance that has 74 members. In that alliance we offer a bank service for all our members, but I - being the leader - am the only one who can access the bank. I have been building a site that works with the game API to gather data for members and create a dashboard. One of the features I am trying to build is allowing them to withdraw from their account instantly.
So, what I need: To be able to submit a POST request to login to the site (specifically on this page --> https://politicsandwar.com/login) with my username and password, but then I need to keep the session active and navigate to a different page (the alliance bank page). On that page I first need to scrape a value from a hidden input (token) and then I need to submit a POST request to this same page while still being logged in.
I am not asking someone to do it for me, but rather someone to help me know how to go about this. I have never submitted post requests with PHP, but I have used PHP cURL in the past. I also have made POST requests with JS, but never PHP.
Thank you so much for anyone that is able to help! |