URL variable from text file
Moderator: General Moderators
URL variable from text file
Is there a way to read the content of a text into a url variable?
Ex: Read "This is the information." from file info.txt
So I would have a variable $a = the line read from the text file.
URL would be header( 'Location: http://somehost.com/test.php?parm1='.$a);
Here is what I tried:
$source = "info.txt";
$a = file_get_contents($source);
header( 'Location: http://somehost.com/test.php?parm1='.$a);
But it doesnt seem to pass anything in the variable. Reason for needing to do this is I have PHP write the file info.txt after files are uploaded (file contains a list of the files that were just uploaded), I then need to pass that list to another page for sending an email confirmation of what files were uploaded.
Thanks in advance,
T.
Ex: Read "This is the information." from file info.txt
So I would have a variable $a = the line read from the text file.
URL would be header( 'Location: http://somehost.com/test.php?parm1='.$a);
Here is what I tried:
$source = "info.txt";
$a = file_get_contents($source);
header( 'Location: http://somehost.com/test.php?parm1='.$a);
But it doesnt seem to pass anything in the variable. Reason for needing to do this is I have PHP write the file info.txt after files are uploaded (file contains a list of the files that were just uploaded), I then need to pass that list to another page for sending an email confirmation of what files were uploaded.
Thanks in advance,
T.
Re: URL variable from text file
Code: Select all
$source = "info.txt";
$a = file_get_contents($source);
header( 'Location: http://somehost.com/test.php?parm1='.$a);Re: URL variable from text file
test.php
<?
$Name = "Me";
$email = "me@host.com";
$recipient = $_GET['email'];
$mail_body = "Your file(s) have been successfully uploaded to the Dev file server, if you need any further assistance please email me@host.com or call 111.222.3333."."\r\n";
$mail_body .= "Files that were uploaded:"." ".$_GET['a'];
$subject = "Files have been uploaded";
$header = "From: ". $Name . " <" . $email . ">\r\n";
ini_set('sendmail_from', 'me@host.com');
mail($recipient, $subject, $mail_body, $header);
//Below sends My copy of upload complete mailer.
$Name2 = "Me";
$email2 = "me@host.com";
$recipient2 = ""me@host.com";
$message = "Name: " . $_GET['name'] ."\r\n";
$message .= "Email: " . $_GET['email'] ."\r\n";
$message .= "Phone: " . $_GET['phone'] ."\r\n";
$message .= "Due Date: " . $_GET['duedate']."\r\n";
$subject2 = "Files have been uploaded";
$header2 = "From: ". $Name . " <" . $email . ">\r\n";
ini_set('sendmail_from', 'me@host.com');
mail($recipient2, $subject2, $message, $header2);
?>
<?
$Name = "Me";
$email = "me@host.com";
$recipient = $_GET['email'];
$mail_body = "Your file(s) have been successfully uploaded to the Dev file server, if you need any further assistance please email me@host.com or call 111.222.3333."."\r\n";
$mail_body .= "Files that were uploaded:"." ".$_GET['a'];
$subject = "Files have been uploaded";
$header = "From: ". $Name . " <" . $email . ">\r\n";
ini_set('sendmail_from', 'me@host.com');
mail($recipient, $subject, $mail_body, $header);
//Below sends My copy of upload complete mailer.
$Name2 = "Me";
$email2 = "me@host.com";
$recipient2 = ""me@host.com";
$message = "Name: " . $_GET['name'] ."\r\n";
$message .= "Email: " . $_GET['email'] ."\r\n";
$message .= "Phone: " . $_GET['phone'] ."\r\n";
$message .= "Due Date: " . $_GET['duedate']."\r\n";
$subject2 = "Files have been uploaded";
$header2 = "From: ". $Name . " <" . $email . ">\r\n";
ini_set('sendmail_from', 'me@host.com');
mail($recipient2, $subject2, $message, $header2);
?>
Re: URL variable from text file
I see a lot of $_GETs in there, but nothing in the URL you posted. According to that, the only variable in the URL is $_GET["parm1"] (which you don't use).
Re: URL variable from text file
header( 'Location: http://www.host.com/test.php?name='.$_POST['name'].'&email='.$_POST['email'].'&phone='.$_POST['phone'].'&duedate='.$_POST['duedate'].'&parm1='.$a) ;
This is the actual redirect I has set the other one up just for testing. I filled in the other variables hardcoded.
This is the actual redirect I has set the other one up just for testing. I filled in the other variables hardcoded.
Re: URL variable from text file
Here is the full code for the page that sends to the test.php.
Code: Select all
<?
if ($_FILES['Filedata']['tmp_name'] && $_FILES['Filedata']['name'])
{
$uploadfile = "uploads/".$_POST['name']." ".date('m-d-y')."/uploads.txt";
$fh = fopen($uploadfile, 'a+') or die("can't open file");
$stringData = $_FILES['Filedata']['name']."\n";
fwrite($fh, $stringData);
//#-- upload the image to the volume folder
$vSourceFile = $_FILES['Filedata']['tmp_name'];
$vImageName = stripslashes($_FILES['Filedata']['name']);
$vFoldername = 'uploads/'.$_POST['name']." ".date('m-d-y')."/";
if(!is_dir($vFoldername))
{
mkdir($vFoldername, 0777); //#-- Create a new session directory
chmod($vFoldername, 0777); //#-- Set all the access permissions to the folder
}
if(copy($vSourceFile,$vFoldername.$vImageName))
$vStatus = 1;
else
$vStatus = 0;
}
else
{
$vStatus = 0;
}
echo '<?xml version="1.0" encoding="UTF-8"?>';
if($vStatus)
echo '<status>1</status>';
else
echo '<status>0</status>';
//Writes instructions files from form data
$ourFileName = uploads/".$_POST['name']." ".date('m-d-y')."/".$_POST['name']."-".date('m-d-y H.i.s').".txt";
$fh = fopen($ourFileName, 'w') or die("can't open file");
$stringData = $_POST['name']."\n";
fwrite($fh, $stringData);
$stringData = $_POST['phone']."\n";
fwrite($fh, $stringData);
$stringData = 'Due on: '.$_POST['duedate']."\n";
fwrite($fh, $stringData);
$stringData = $_POST['email']."\n\n";
fwrite($fh, $stringData);
$stringData = $_POST['details']."\n\n";
fwrite($fh, $stringData);
$source = "uploads.txt";
$html = file_get_contents($source);
$filelist = urlencode($html);
//Email after uploading...
header( 'Location: http://www.host.com/mailtest.php?name='.$_POST['name'].'&email='.$_POST['email'].'&phone='.$_POST['phone'].'&duedate='.$_POST['duedate'].'&parm1='.$filelist) ;
?>
Re: URL variable from text file
Code: Select all
if($vStatus)
echo '<status>1</status>';
else
echo '<status>0</status>';And there's still the fact that $_GET["a"] doesn't exist but $_GET["parm1"] does.
Re: URL variable from text file
The $_GET['a'] was a sub for $_GET['parm1'] parm1 is the real name.
Strange part is this seems to work fine when it type it into the address bar directly.
Strange part is this seems to work fine when it type it into the address bar directly.
Re: URL variable from text file
Matter still stands:
tasairis wrote:You can't call header() after outputting something.
Re: URL variable from text file
Thanks man I fixed it by taking the redirect out of that page and placing it into another page and just setting my app to hit both pages instead of just one.
_____App______
| |
upload.php redirect.php
|
email.php (on different server so Flex wont let me go direct to it)
_____App______
| |
upload.php redirect.php
|
email.php (on different server so Flex wont let me go direct to it)