PHP - Post Data And Redirect To Other Domain
Hello all,
I have this issue: I have a form with several fields. I need to save to a session variable (in submit page) all of the fields upon submit and then post some of the fields to a https site using a POST request (i.e., doing a header('Location: https://mynewdomain.com/page.cfm?'.$data) won't cut it). Now, I can do it with javascript... a whole bunch of hidden fields in the between page and then auto submit the form to the mynewdomain.com domain using the post method. I am wondering whether there would be a better way for that. I know that Curl does it, with one glitch. When I set the parameter CURLOPT_FOLLOWLOCATION to true it redirects the user BUT it doesn't load any css or javascript from the new page. People say on the web to do a request for each file but I haven't figured out how to do it. Can anyone post an elegant/concrete solution to this problem or should I resort to Javascript? Thanks menwn Similar TutorialsHi,
I have an address on my main server http://www.website.com/directory and would like to redirect it to a subdomain http://subdomain.website.com/directory
The subdomain is not pointing to the same server as the main domain.
How would I set up a redirect in htaccess?
Thanks!
This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=359577.0 Hey everyone... Been over a year or more since I have had seek help here but I have something that I just do not understand. I am submitting a from from one domain - www.mydomain.com - to a form handler on another domain - www.theirdomain.com all under https. The form data is getting to theridomain.com just fine, the other side is handling it properly and all is well there. The issue is they are taking the response they generate and shipping it out via cURL using the below (they were nice enough to share this with me). Code: [Select] $url = $_SESSION['request']['retUrl']; $fields = array( 'hash'=>rawurlencode($hash), 'responseText'=>rawurlencode($_SESSION['response']['responseText']), 'cid'=>rawurlencode($_SESSION['request']['cid']), 'name'=>rawurlencode($_SESSION['request']['name']), 'actCode'=>rawurlencode($_SESSION['response']['actCode']), 'apprCode'=>rawurlencode($_SESSION['response']['applCode']), 'Token'=>rawurlencode($_SESSION['response']['token']), 'req_number'=>rawurlencode($_SESSION['request']['req_number']), ); foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); if (isset($_SESSION['request']['Address1'])) { $Address = array( 'Address1'=>rawurlencode($_SESSION['request']['Address1']), 'Address2'=>rawurlencode($_SESSION['request']['Address2']), 'City'=>rawurlencode($_SESSION['request'][City']), 'State'=>rawurlencode($_SESSION['request'][State']), 'Zip'=>rawurlencode($_SESSION['request']['Zip']), 'Country'=>rawurlencode($_SESSION['request']['Country']), ); foreach($Address as $key=>$value) { $Address_string .= $key.'='.$value.'&'; } rtrim($Address_string,'&'); } $end = array( 'END'=>"END" ); foreach($end as $key=>$value) { $end_string .=$key.'='.$value; } rtrim($end_string,'&'); I have worked for almost a week and I CANNOT snag the incoming data! All I am trying to do is collect this and convert it into $_SESSION data for use on a success page. If any one has any thoughts or in site, please.... $post='{"cart_items":[{"configuration":{"price":100,"recharge_number":"9999999999"},"product_id":"999","qty":1}]}';i try this n reslut was :There are no valid items in cart: help me plz Edited by ShivaGupta, 30 November 2014 - 01:11 AM. Friends, I want to check a site if there is any data avaliable for a given Domain Name.... For example Quote http://www.keywordspy.com/research/search.aspx?tab=domain-organic&market=uk&q=abc.co.uk In this URl the Domain is the "&q=" POST Parameter which is: abc.co.uk In the Output, Observe the Columns Keyword, Position, Volume etc.... So for any Domain we want to check if there is one or more keyword returned. Here is the Example of a Domain for which there is no Data: Quote http://www.keywordspy.com/research/search.aspx?tab=domain-organic&market=uk&q=notfoundforme.co.uk As you Observe there is no data in Keyword, Position or Volume Columns for this Domain (i.e. notfoundforme.co.uk) All i want is to Echo All the Keywords, their Position and Volumes for any domain for which data is avaliable. Code: Here is the Code i have which scrapes the Whole data with Curl, but i am not able to make getkwspydata function work to get the Keyword, Position or Volume data for the domain, i know some regex and preg_match needs to be done but its too technical for me, may someone help me with this? <?php function getkwspydata($host) { $request = "http://www.google.com/search?q=" . urlencode("site:" . $host) . "&hl=en"; $request = "http://www.keywordspy.com/research/search.aspx?tab=domain-organic&market=uk&q=". urldecode($host); $data = getPageData($request); // preg_match('/<div id=resultStats>(About )?([\d,]+) result/si', $data, $p); // $value = ($p[2]) ? $p[2] : "n/a"; // $string = "<a href=\"" . $request . "\">" . $value . "</a>"; //return $string; print_r($data); } function getDomainName($host) { $hostparts = explode('.', $host); // split host name to parts $num = count($hostparts); // get parts number if(preg_match('/^(ac|arpa|biz|co|com|edu|gov|info|int|me|mil|mobi|museum|name|net|org|pp|tv)$/i', $hostparts[$num-2])) { // for ccTLDs like .co.uk etc. $domain = $hostparts[$num-3] . '.' . $hostparts[$num-2] . '.' . $hostparts[$num-1]; } else { $domain = $hostparts[$num-2] . '.' . $hostparts[$num-1]; } return $domain; } function getPageData($url) { if(function_exists('curl_init')) { $ch = curl_init($url); // initialize curl with given url curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // add useragent curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // write the response to a variable if((ini_get('open_basedir') == '') && (ini_get('safe_mode') == 'Off')) { curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // follow redirects if any } curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); // max. seconds to execute curl_setopt($ch, CURLOPT_FAILONERROR, 1); // stop when it encounters an error return @curl_exec($ch); } else { return @file_get_contents($url); } } $sitehost = ($_POST['sitehost']) ? $_POST['sitehost'] : $_SERVER['HTTP_HOST']; $sitedomain = getDomainName($sitehost); ?> <html> <head> <title>SEO Report for <?=$sitedomain;?></title> </head> <body> <form method="post" action="<?$_SERVER['PHP_SELF'];?>"> <p><b>Domain/Host Name:</b> <input type="text" name="sitehost" size='30' maxlength='50' value="<?=$sitehost;?>"> <input type="submit" value="Grab Details"></p> </form> <ul> <li>Google indexed pages: <?=getkwspydata($sitehost);?></li> </ul> </body> </html> Cheers Natasha T. Hello, Thanks for reading this. I'm working on a project where the homepage should be a Today's Deal and I'm using the Auto delete posts plugin to move the Today's Deal to the "Previous Deals" Category, after 24 hours. My task is to automatically redirect the homepage to the only post in Today's Deal Category, which will have different permalinks everyday. I'm querring the post with: <?php query_posts("cat=41&showposts=1"); ?> And I tried redirecting to the result with: <?php $url = the_permalink(); header("Location: $url"); ?> just after query_posts... but no success. I tried several other things too, apart from searching the web a lot before posting here. Help! Anyone? Thanks in advance! I have a web page that uses $_POST to pass the ID from web page to web page as they fill out forms using$ID=$_POST['id']The last page of the form passes this and other information to a php page that inserts the information that was passed into a database I have set up and then redirects back to the first page of the form. This is what I have so far. <?php // Change to the URL you want to redirect to $URL="Start.php"; header ("Location: $URL"); $ID=$_POST['id']; ?> What I want to happen however is when it redirects, I want it to pass the ID information back to the main page again as well. Can anyone help me out? Hi guys, I think I may be losing my marbles over this form I've put together. I'm trying to get my code to post the following to a database but my MySQL and PHP isn't that good, so wondering if any one could possibly suggest what I could do? Here is my code: Code: [Select] <?php // we check if everything is filled in if(empty($_POST['fname']) || empty($_POST['lname']) || empty($_POST['email'])) { die(msg(0,"All the fields are required")); } // is the sex selected? if(!(int)$_POST['sex-select']) { die(msg(0,"You have to select your sex")); } // is the birthday selected? if(!(int)$_POST['day'] || !(int)$_POST['month'] || !(int)$_POST['year']) { die(msg(0,"You have to fill in your birthday")); } // is the email valid? if(!(preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $_POST['email']))) die(msg(0,"You haven't provided a valid email")); // I think here is where I need to put something to get the data into a table! echo msg(1,"registered.html"); function msg($status,$txt) { return '{"status":'.$status.',"txt":"'.$txt.'"}'; } ?> How do I get the $_POST['day'] and $_POST['month'], $_POST['year'] etc into a table? It should be so easy but my head is hurting from trying lots of things and tutorials online. Any thoughts my PHP Freaks? im trying to understand this Post Data script it's not posting, no errors: postdata.php Code: [Select] <?php //create array of data to be posted //$post_data['firstName'] = 'Name'; $post_data['item_name'] = '12345'; //traverse array and prepare data for posting (key1=value1) foreach ( $post_data as $key => $value) { $post_items[] = $key . '=' . $value; } //create the final string to be posted using implode() $post_string = implode ('&', $post_items); //we also need to add a question mark at the beginning of the string $post_string = '?' . $post_string; //we are going to need the length of the data string $data_length = strlen($post_string); //let's open the connection $connection = fsockopen('www.example.com', 80); //sending the data fputs($connection, "POST /i.php HTTP/1.1\r\n"); fputs($connection, "Host: www.example.com \r\n"); fputs($connection, "Content-Type: application/x-www-form-urlencoded\r\n"); fputs($connection, "Content-Length: $data_length\r\n"); fputs($connection, "Connection: close\r\n\r\n"); fputs($connection, $post_string); //closing the connection fclose($connection); ?> reuslt should be posted here i.php Code: [Select] <?php require('database_connection.php');?> <?php if(isset($post_items[0])) { //$Subscription_id = mysql_real_escape_string($md5c); //$PropertyID = mysql_real_escape_string($rowData['ID']); //$User_ID = mysql_real_escape_string($rowData['User_ID']); $item_name=mysql_real_escape_string($post_items[0]); $query = 'INSERT INTO SP_subscriptions(id,) values("'.$item_name.'")'; //$query = 'INSERT INTO SP_subscriptions(id,PropertyID,User_ID) values("'.$item_name.'","'.$PropertyID.'","'.$User_ID.'")'; $success = mysql_query($query); } else { $item_name=54321; $query = 'INSERT INTO SP_subscriptions(id) values('.$item_name.')'; //$query = 'INSERT INTO SP_subscriptions(id,PropertyID,User_ID) values("'.$item_name.'","'.$PropertyID.'","'.$User_ID.'")'; $success = mysql_query($query);} //var_dump($_POST); //var_dump($query); echo $query; ?> Hi I have a little strange problem. I cannot get the post data from my form. It works fine if there is 10 or 15 user but reaching 40 or more than form values not posting. This is output of size: echo (int) $_SERVER['CONTENT_LENGTH']; ===== 22164 Code: [Select] if(isset($_POST['hiddenField'])) { // do some work; } $sql = mysql_query("SELECT id, name FROM user WHERE shop_id = '" .$_SESSION['id']. "' ORDER BY name ASC"); while($row = mysql_fetch_array($sql)) { echo ' <div style="width:100%; border:solid 1px #CCC; background-color:#f1e7e7; margin-bottom:5px;"> <table class="tableSmall"> <tr><th width="81">' .$row['name']. '</th><th width="71">'; echo $grl_pic .' </th> <td width="622"><table width="100%"> <tr>'; for($j=0; $j<7; $j++) { $sql2 = mysql_query("SELECT user_master_id, user_start, user_end FROM work_master WHERE user_master_id = '" .$row['id']. "' AND date = '" .$days_no_kanji[$j]. "'"); $row2 = mysql_fetch_array($sql2); if(mysql_num_rows($sql2) == 0) { $start = "00:00"; $end = "00:00"; $m = 0; } else { $start = $row2['user_start']; $end = $row2['user_end']; $m = 1; } echo ' <th><input type="hidden" name="userData[]" value="' .$row['id']. '_' .$j .'_' .$m. '" /> <select name="' .$row['id']. '_' .$j .'_' .$m. '_start">' .ShopHour($start). '</select><br />~<br /> <select name="' .$row['id']. '_' .$j .'_' .$m. '_end">' .ShopHour($end). '</select> </th>'; } echo ' </tr> </table></td> </tr> </table> </div>'; } Is there someone has any idea why php is not posting? Hi All, Not sure if this is a silly question so here we go. I have some divs that have data attributes (data-value). When i submit and post the form, can i use these values as part of the submission and put their data-value into the db? Thanks as always in advance. i am trying to fit this php code to so when ever i upload a video link to the database it prints in the divs from left to right. ( i have made blank boxes for where the videos should be, so you guys can see what i mean. i will give you the code here. Code: [Select] <?php $query = mysql_query("SELECT * FROM `G4V_Videos` ORDER BY `id` DESC") or die(mysql_error()); while ($data = mysql_fetch_array($query)) { ?> ID-nummer: <?php print $data['id']; ?> - Name: <?php print $data['navn']; ?> - <a href="/Video.php?id=<?php print $data['id']; ?>"><img src="http://i.ytimg.com/vi/<?php print $data['link'];?>/hqdefault.jpg" width="200" height="160" /></a><br /> <a href="/Video.php?=<?php print $data['id']; ?>"> <?php } ?> and the website is here, http://www.game4vids.com/index.php and i also want it so once i have used up all the boxes it posts the new video in box one and overwrites the old one if you get what i mean. This website is a great example of what i mean. http://www.retardo.dk I'm doing an ajax call from javascript using jquery library: Code: [Select] ajaxCall: function(process, obj, type){ $.post("registration-post.php", type + "=" + process, function(data){ if(data==""){ $(obj).css(registration.errorNotificationType, registration.validatedColour); }else{ $('.error').append($.trim(data) + "<br />"); $(obj).css(registration.errorNotificationType, registration.errorColour); registration.progress = false; } } ); } When the ajax calls the php page, I want the php page to know what post information the javascript has sent, rather than pre-defining what the PHP should be trying to retrive from the POST data. Something like // pseudo $_POST["whateverwassentfromajax"] I want to do this because I want to have one function doing everything. So in my javascript I am saying, check if the username and email have already been used... But i dont want to call two different php functions. //pseudo function 1(){ $_POST["username"]; } function 2(){ $_POST["email"]; } Is there a special way to know which post data has been sent. Or do i need to do a few if statements in php. Hi guys, I am creating a quiz system for my personal site, I am done with all the quiz questions creating part, but I am stuck with something like... user taking a random sql generated quiz and submitting it.. Here's randomly generated sql quiz, even the answers are in random order: <form method="post"> <b>1. What is color or sky</b> <ol> <li><input name="question_3_answer" type="radio" value="6" /> sky</li> <li><input name="question_3_answer" type="radio" value="8" />blue</li> <-- true <li><input name="question_3_answer" type="radio" value="3" />red</li> </ol> <b>2. What is name of my cat</b> <ol> <li><input name="question_6_answer" type="radio" value="9" />brat</li> <--true <li><input name="question_6_answer" type="radio" value="7" />rat</li> </ol> <b>3. What is name of my pet</b> <ol> <li><input name="question_18_answer" type="radio" value="9" />cat</li> <--true <li><input name="question_18_answer" type="radio" value="7" />dog</li> </ol> </form> Now this is tricky part for me is.. receiving these data in another page.. since it's randomly generated questions, how do I know which question it is? here's example I've tried : $list_all_quiz_questions = $db->get_row("SELECT question_id, its_true_ans_id FROM question_table WHERE quiz_group = 'ef23fsdfers3e' "); $i = 1; foreach ($list_all_quiz_questions as $myquestion) { $answer.$i == $_POST["question_".$myquestion->question_id."_answer"]; //?????????? not working lol ;(( $i++ } Hello, I need to post plenty of data to a file with a java file with a .do extension using a php program. How do I get to auto-post mass data in php from a database straight to this java file? Put in mind that each mysql record is posted as its own form as in: <form ...>mysql record</form> Thanks in advance Hello
I have a nusoap web service running, which is fine, but I need to send a new variable in the parameters which decides what database to use...
This is how I call the function:
$params = array( 'region' => '1' ); $response1 = $client->call('function1', array ($params)); // response will be in JSON So basically I'm using PHP to solve a math problem for me. The user puts in a few parameters and the program runs those numbers through the algorithm and spits out a bunch of xy coordinates. I'm using the PHP SELF method to retrieve the user input. This all works fine, but it's afterwords that I run into problems. I create a drop down menu of all the x values and I want the user to be able to choose any x value they wish and to have the corresponding y value be displayed. The problem is that I have to use another POST command for this and when I do, it wipes out all the computed data. Of course the y-value is never displayed, and there lies the problem. I'm sure there are many ways to get around this, but I could not find one out myself. Anyone have any ideas? I have two domains both running SSL. Let's call them old-domain and new-domain. old-domain is permanently redirecting traffic to new-domain. There are still a lot of links out there to old-domain with https://. If I were to remove SSL from old-domain but keep SSL on new-domain, I am betting that users will be getting some sort of certificate error. Right? Any way around that if I want to remove SSL from old-domain?
This topic has been moved to the corner of 3rd Avenue and mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=359430.0 Hello guys. I have a form with 20 images. My user have to write a description for each image and when submitting the form the user will get an HTML code which will display an album. My problem is that my users want to choose a sequence of the images in the album. How do I solve that? I tried with making a select with 20 options (number 1-20) for each image and a desription for the user to place them in a correct sequence but I don't know how to do it. And another problem is when a user chooses the same number for more than one image. Thanks |