Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am trying to redirect a login page to go to another page on my web app using P

ID: 3830711 • Letter: I

Question

I am trying to redirect a login page to go to another page on my web app using PHP. I have the following two lines of code within a conditional statement. I am trying to get the page to go to the main part of my web application if the user provides valid username and password. this code isnt working to send the browser to the other php file on my server. Please help, I will upvote clear helpful response.

header("Location:http://students.oneonta.edu/username/csci/TermProject/mainpage.php");

exit;

Explanation / Answer

Put the space between the 'Location: http://.....' like shown below

header('Location: http://students.oneonta.edu/username/csci/TermProject/mainpage.php');

And Try adding ob_start() at the top of the code i.e. before the include statement

Note: The function ob_start() will turn output buffering on. So browser will not receive any output and the header will work, also make sure that header() is used on the top of the code.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote