The following code in separate.php passes values from form to receiving file: form -> separate.php file -> vendor's receiving file <?php $url="https://receivingsite.com/receive.jsp?"; foreach($_POST as $key => $value) { $url .="$key=" . urlencode($value) . "&"; } header ("Location: $url"); ?> Code (markup): Now I find that upon receiving the values, the receiving file opens a default page that I don't want visitors to see and any other code in my separate.php file does not execute. What can I change in my separate.php file to execute whatever other code I include in it?
How can the rest of the php code execute if you redirect to another file (header ("Location: $url") ? I don't understand what you want to do. Execute more code in separate.php ? Place that code before header ("Location: $url");
Yes, I want to execute more code in separate.php. I was not correct when I indicated that all other code does not execute. Only part of it does not execute. I place whatever other code it is (all working), ahead of the code in question. The portion of the other code that sends an email to me containing the values from the form, still works. The portion of the other code that opens another page, does not open it any more. Instead, an unwanted (to me) confirmation page generated by the vendor's receiving file opens instead of the page specified in my other code. This is the part that does not open any more: print "<meta http-equiv=\"refresh\" content=\"0;URL=http://mywebsite.com/next.htm\">"; Code (markup): I have to send to their receiving file with the confirmation page because the regular one they designed for this purpose (no confirmation page) requires that the form's redirect field be included, and that is a problem to me (not to most of their customers) because I have two buttons in the form going to two different pages, instead of one button like all their other customers would have. The receiving file (confirmation page) that I have to send to was designed with a different use in mind, but I have to send to it because the regular one must receive a form field that I do not want to include. So it seems that I need to replace header ("Location: $url"); with something else, or make some other change or addition. Any suggestions?
Sound to me like you are trying to send headers twice. Do you have that warning with "Cannot resend headers information" ? You can use ob_start(); at the beginning of the file and ob_end_flush(); at the end
I appreciate your interest in my problem and setting me off in the right direction to find a replacement for header ("Location: $url"). I have found the answer which I am now pleased to share with you. The solution is what your post suggested to me, replace header ("Location: $url"). Note that it is not sufficient to just place the other code before header(). That replacement turns out to be: $array = file($url); //Reads File To Array Code (markup): Substituting that into the code, I now have: <?php $url="https://receivingsite.com/receive.jsp?"; foreach($_POST as $key => $value) { $url .="$key=" . urlencode($value) . "&"; } $array = file($url); ?> Code (markup): As far as I can tell, header ("Location: $url"); transferred browser control to the receiving file, receive.jsp, resulting in the vendor's unwanted confirmation page opening as that file would have it. But now, $_POST sends $array to the receiving file, leaving browser control with my file, separate.php, allowing my other code to open the page I want to open as my file would have it. The overall result is a concise and elegant code solution for which I take no credit because it was all suggested, piece by piece, by helpful forum people. As a php challenged person, I thank all forum contributors for their efforts.