my html file look like this
<form action="cnvrt.php" method="POST" >
Enter your text here - <input type="text" id="in" name="in"> <br>
<input type="submit" value="submit" >
</form>
my php file is like this
$in = $_POST['in'];
$url = "https://translate.google.com/translate_a/single?client=t&sl=auto&tl=si&hl=en&dt=bd&dt=ex&dt=ld&dt=md&dt=qc&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&prev=btn&rom=1&ssel=0&tsel=0&tk=517882|775443&q=$in";
header( "Location: $url" );
Then i get the html response as f.txt file. I need to save the content of this file in to a variable insted of saving the file.
How could I do this? Is it possoble to do this?
Untested but you can perhaps do something like:
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['in'])) {
$in = $_POST['in'];
$url = "https://translate.google.com/translate_a/single?client=t&sl=auto&tl=si&hl=en&dt=bd&dt=ex&dt=ld&dt=md&dt=qc&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&prev=btn&rom=1&ssel=0&tsel=0&tk=517882|775443&q=".$in;
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$your_var = curl_exec($ch);
curl_close($ch);
}
?>