This may be a stupid question, but what is the right way to redirect the user to the success page after saving the form in the database?
I donβt know why, but if I add action="done.php" , the form will not save the data in my database.
I tried adding header ("location:/done.php"); , it worked, but when I moved the page to the source server (PHP 4 and MySQL 3.23.5), an error occurs when I try to submit the Warning: Cannot modify header information - headers already sent by ........
Here is my PHP code:
if(isset($_POST['submit'])) { $name=$_POST['name']; $email = $_POST['email']; $company = $_POST['company']; $adress = $_POST['adress']; $post = $_POST['post']; $phone = $_POST['phone']; $sql="INSERT INTO tekstile_users (id, name, email, company, adress, post, phone) VALUES ('', '$name','$email','$company', '$adress', '$post', '$phone')"; if (mysql_query($sql,$con)) { header ("location:/done.php"); } else { echo "Something is wrong"; } }//end of submit button
I fix by converting this .php file to UTF-8 without BOM .
Thanks everyone for the suggestions!
redirect php submit forms
iKaspars
source share