Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
898 views
in Technique[技术] by (71.8m points)

php - redirect after post?

I have a php page for submitting resumes. once they click submit they info all posts to mail.php

once the mail is sent i would like the user to go back to a different page on the website (where the job opportunity are located)

is is there any sort of command i can use to redirect to a different page after the mail.php is done with its business??

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is a standard redirection in PHP:

<?php
header( 'HTTP/1.1 301 Moved Permanently' );
header( 'Location: http://www.example.com' );
exit;
?>

However, in your case the 301 redirection line is probably not necessary. It should be noted that the exit is necessary, otherwise the rest of your PHP script will be executed, which you may not want (e.g. you may want to display something if there is an error).

Also, the header function must be called before any output is sent to the browser (including blank lines). If you're unable to avoid some blank lines, put ob_start(); at the start of the script.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...