Skip to content Skip to sidebar Skip to footer

Post Parameters Not Working In File_get_contents() Php

I had two PHP files on my same server, Where one PHP file is used to send the mail and the other PHP file is what will be the body of the other mail so, I do this like this

Solution 1:

file_get_contents() returns the file in a string as it is, it will not pass any existing variables, for that you will need to use include or require.

http://php.net/manual/en/function.file-get-contents.php

What you can do is inside Judgement6.php create the variable $email_text and then include the file in your script.

Inside Judgement6.php:

$mail_text = "ALL THE CONTENT AND $VARIABLES INSIDE Judgement6.php";

For example, if Judgement6.php has the following script:

Hello <?phpecho$name; ?>,
Thank you for subscribing to our <?phpecho$_POST['service']; ?> 
on <?phpecho date("Y-m-d"); ?>.

You will write

$mail_text = "Hello  $name,
Thank you for subscribing to our ".$_POST['service']." 
on ".date("Y-m-d").".";

Be careful with concatenation and using " inside the string, you will need to escape them \"

In your file


$to=$email;
$subject="Welcome Aboard| Judgement6";    
include_once('Judgement6.php');

or


$to=$email;
$subject="Welcome Aboard| Judgement6";  
require_once('Judgement6.php');

Post a Comment for "Post Parameters Not Working In File_get_contents() Php"