0

I've looked at so many stack overflow questions to find my solution, but none of the questions I try are what I am looking for (so if you know of one that fits my question, please tell me). What I have is a php page that processes a form. It looks like this:

<?php
$var1 = htmlentities($_POST['var1']);
$var2 = htmlentities($_POST['var2']);

$conn = mysqli_connect('localhost','user','pass','db');
$query = "INSERT INTO table (var1,var2) VALUES ('$var2','$var2)";
$doQuery = mysqli_query($conn,$query);

if($doQuery) {
    // this is where script should go (i think) to send the variables to the email page
header("Location: /path/to/next/page"); // this just sends the user to the next page. NOT PART OF EMAIL PAGE
}

else {
header("Location: /path/to/back/page");
}

mysqli_close($conn);
?>

so its a basic form handler that sends you to the next page if all goes well.

I have another page that is sends an email notification to someone when they successfully go through the first page. It also processes all of the other email notification worthy forms as well. that's the reason I can't just take the script and put it into the top page.

So, what I am trying to do is figure out a way to send the $var1 and $var2 to the email file without completely redirecting the user. I don't need a response back from the email file.

I hope that made sense.

thanks in advance

4
  • You just want to include the file where its needed php.net/manual/en/function.include.php Commented Aug 12, 2015 at 22:19
  • you have a syntax error - echo 'error'; doesn't help you, if that's your actual code. Commented Aug 12, 2015 at 22:21
  • its not. thanks though @Fred-ii- Commented Aug 12, 2015 at 22:23
  • it (still) is for future readers ;-) please edit respectively Commented Aug 12, 2015 at 22:24

1 Answer 1

3

Quite simple, really:

// your code above
require 'send-email.php';

And your send-email.php would reference $var1 and $var2.

Sign up to request clarification or add additional context in comments.

2 Comments

so I wouldn't need to $_GET or $_POST the variables?
@phprunner No - try it and you'll see.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.