Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKonrad Pilch
2,435 PointsWhy my rederict doesnt wokr?
Why my rederict doesnt work? i mean the header location ..
if(mysqli_query($con, $query)){
echo "Records added successfully.";
header ("location:register.php");
exit();
1 Answer
Ryan Field
Courses Plus Student 21,242 PointsPHP is a server-side script that pre-processes your HTML. That means that once you output to the page, you can no longer affect the header and tell the page to relocate. You can get around this by hard-coding in a meta redirect tag or using JavaScript, but that specific code is not possible in that format.
Konrad Pilch
2,435 PointsKonrad Pilch
2,435 PointsSo what should i do once the button is clicked and the data is submited?
Actually, i just did it this way and it works:
I just took that off, and the message echo on the page , the same page saying it was added. : p i dont know if thats ok wiith all.