sphinx666 Posted January 16, 2009 Share Posted January 16, 2009 I am putting together a registration form for a parent to enter their information into a webpage. The form takes all their information, inserts it into a database and then I need it to redirect to a thank you page. It currently does all of that, except that when it goes to the thank you page it says the following error: [an error occurred while processing this directive] I've been trying to figure this out for a while now - would be grateful for any help! Thanks! My code looks like this: <?php ob_start(); ?> [css tags] [javascript that checks to ensure the form inserts are valid] <form method="post" name="regform"> <?php if(isset($_POST['btnSubmit'])) { include 'config.php'; include 'opendb.php'; $parentfirstname = $_POST['txtParentFirstName']; $parentlastname = $_POST['txtParentLastName']; $query = "INSERT INTO table_name (parentfirstname, parentlastname) VALUES ('$parentfirstname', '$parentlastname')"; mysql_query($query); include 'closedb.php'; ob_end_clean(); header('Location: http://www.sitename.com/thankyou.html'); } ?> </form> Link to comment https://forums.phpfreaks.com/topic/141102-need-help-with-simple-redirectform-please/ Share on other sites More sharing options...
Nimbuz Posted January 16, 2009 Share Posted January 16, 2009 Ah, I'm working on my first form and I need this too. :-) Link to comment https://forums.phpfreaks.com/topic/141102-need-help-with-simple-redirectform-please/#findComment-738520 Share on other sites More sharing options...
akitchin Posted January 16, 2009 Share Posted January 16, 2009 my guess is that it has something to do with your output buffering. what is the exact error you receive? Link to comment https://forums.phpfreaks.com/topic/141102-need-help-with-simple-redirectform-please/#findComment-738522 Share on other sites More sharing options...
flyhoney Posted January 16, 2009 Share Posted January 16, 2009 Why don't you restructure your form so you don't have to deal with the ob_start() business? <?php if(isset($_POST['btnSubmit'])) { include 'config.php'; include 'opendb.php'; $parentfirstname = mysql_real_escape_string($_POST['txtParentFirstName']); $parentlastname = mysql_real_escape_string($_POST['txtParentLastName']); $query = " INSERT INTO table_name SET parentfirstname = '$parentfirstname', parentlastname = '$parentlastname' "; mysql_query($query); include 'closedb.php'; header('Location: http://www.sitename.com/thankyou.html'); } ?> [css tags] [javascript that checks to ensure the form inserts are valid] [html form] Link to comment https://forums.phpfreaks.com/topic/141102-need-help-with-simple-redirectform-please/#findComment-738523 Share on other sites More sharing options...
rascle Posted January 16, 2009 Share Posted January 16, 2009 Why dont in the HTML form bit you change it to: <form name="..." method="...." action="...."> On the dotdotdot change it to whatever and in the action bit put in the thank you page url. Link to comment https://forums.phpfreaks.com/topic/141102-need-help-with-simple-redirectform-please/#findComment-738710 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.