简体   繁体   中英

navigate from one php page to another php page

Yes this question has been asked before but we are including one step that we have not seen in any other answers. This question involves three pages one HTML and two PHP pages. The HTML page has a reCaptcha that is verified when the user clicks the SEND button that navigates to the verify.php page. It has your standard true or false if statements code below

if ($captcha_success->success==false) {
    echo "<p>You are a bot! Go away!</p>";
} else if ($captcha_success->success==true) {
    header('location:https://androidstackoverflow.com/contactform/send-
 info.php');/* page on the server */
    echo "<p>You are not not a bot!</p>";*/
}

This is where the fail or lack of results starts. if true we want to navigate to send-info.php and send the info to the server. We can not see the code in send-info.php load or execute. We know the code works by adding it inside the true if statement So the question is this a fail because the send-info.php is not loading or no variable info is being received from the HTML page with the data? Web Page can be seen here Web Page We are not web developers and this is the only PHP code we have ever written. It has taken 5 days to get this far with the contact form so we are desperate ! For clarity contactform is a folder and all three forms are in this folder we have tried with out contactform in the path

When you view the source code it contains

1 
2 <p>You are not not a bot!</p>

when you should only see

1 <p>You are not not a bot!</p>

Which implies there has been some white space outputted somewhere in the PHP file prior to the header command and I suspect you have warning/error reporting turned off otherwise you would have gotten the following warning appearing: "Cannot modify header information - headers already sent by (output started at..." The solution is to make sure there are no empty lines before the

<?php 

at the top of the php file.

Also try turning on error reporting... and it'll tell you where the first output occurred

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

Remember to remove the error reporting code once you've fixed it.

This post goes into extensive details of the cause and solutions How to fix "Headers already sent" error in PHP

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM