Jump to content

Need help with simple redirect/form... please!


sphinx666

Recommended Posts

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>

 

 

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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.