SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist
    Join Date
    May 2007
    Location
    Kent in Uk
    Posts
    538
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    form not redirecting to thank you page

    hi,

    I have create a form using php and mysql. The form works fine. It places the information from the submitted form in the database and sends one email to the user and one email to me saying the form has been filled in.

    However it does not redirect to the thank you page once the form has been sent. An error page comes up saying there is an internal error.

    I looked at my error logs and this is what came up:

    the-bee-scene.com [Tue Jan 19 11:55:18 2010] [error] [client 94.3.186.201] malformed header from script. Bad header=/home/sites/the-bee-scene.com/: briefing.php, referer: http://www.the-bee-scene.com/briefing.php

    The php on my page:
    PHP Code:
    <?php require_once("includes/connection.php");
    include (
    "includes/functions.php");
    //form validation
    if(isset($_POST['submit'])){
    $errors=array();
    $requiredfields=array('site_use'=>'Please enter web site type','biz_type'=>'Please enter your business details','market'=>'Please enter the market question','style'=>'Please answer the style question If not sure just put unsure','message'=>'Please answer the message question If not sure just put unsure','branding'=>'Please answer the branding question If not sure put unsure','budget'=>'Please enter a budget figure','images'=>'Please state if you can provide images','name'=>'Please enter your name','email'=>'Please enter your email so we can contact you','aftercare'=>'Please state if you are wish to have aftercare services');
    foreach(
    $requiredfields as $fieldname => $requiredfieldsmessage){
    if(!isset(
    $_POST[$fieldname]) || empty($_POST[$fieldname]) || strlen(trim($_POST[$fieldname])) == 0/*|| $_POST[$fieldname]==""*/ {
    $errors[] = $requiredfieldsmessage;
    }
    }
     if(
    count($errors) == 0){
     
     
    $_POST array_map('mysqli_prep'$_POST);
     
    //end form validation
    $name  mysqli_prep($_POST['name']);
    $email  mysqli_prep($_POST['email']);
    $tel  mysqli_prep($_POST['tel']);
    $site_use  mysqli_prep($_POST['site_use']);
    $biz_type  mysqli_prep($_POST['biz_type']);
    $market  mysqli_prep$_POST['market']);
    $style  mysqli_prep$_POST['style']);
    $message  mysqli_prep($_POST['message']);
    $branding  mysqli_prep($_POST['branding']);
    $budget  mysqli_prep($_POST['budget']);
    $images  mysqli_prep($_POST['images']);
    $aftercare mysqli_prep($_POST['aftercare']);
    $query "INSERT into briefing_form (
    name,email,tel,site_use,biz_type,market,style,message,branding,budget,images,aftercare)Values('
    {$name}','{$email}','{$tel}','{$site_use}','{$biz_type}','{$market}','{$style}','{$message}','{$branding}','{$budget}','{$images}','{$aftercare}')";

    $result mysqli_query($connection$query);
    $message="You have recieved a briefing form";
    $subject="briefing form";
    $subject2="Your Quote";
    $message2="Thank you for contacting Markets 2000. We will forward a quote to this address.";
    $email2=$email;
    mail('njc27@sky.com',$subject,$message);
    mail($email2$subject2$message2);
    header('Location:brief_return.php');
    exit;
    }
    }
    ?>
    (even though the function file is included on this page there are no functions or php in the rest of the page which is just the form and html)

    Can any one help me with this?

    thanks

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    I'm not absolutely sure but you don't have a space after the colon (as shown in the manual), and you don't specify the relative path from the domain root.

    http://fr2.php.net/manual/en/function.header.php
    PHP Code:
    header('Location: /brief_return.php'); 
    I think the lack of a space is a showstopper, and not starting at the top of the domain root (or specifying, or generating the path to the file) is just a preference I tend to use.

  3. #3
    SitePoint Evangelist
    Join Date
    May 2007
    Location
    Kent in Uk
    Posts
    538
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Cups View Post
    I'm not absolutely sure but you don't have a space after the colon (as shown in the manual), and you don't specify the relative path from the domain root.

    http://fr2.php.net/manual/en/function.header.php
    PHP Code:
    header('Location: /brief_return.php'); 
    I think the lack of a space is a showstopper, and not starting at the top of the domain root (or specifying, or generating the path to the file) is just a preference I tend to use.

    I have tried adding a space and i have put the whole domain root in (http://www.the-bee-scene.com/brief_return) and I have tried using "" instead of ''. i have also tried using the / and the ./ but none of these are working. Strangely enough it works on my local computer no problem.

    Help!

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    151 Post(s)
    Tagged
    3 Thread(s)
    Not all header instructions are to do with redirection.....
    mail() function uses headers too, check that your mail function is all correct and that the fields are there - echo them out to see.

    Also check up in the manual about which headers are required.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  5. #5
    SitePoint Evangelist
    Join Date
    May 2007
    Location
    Kent in Uk
    Posts
    538
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spikeZ View Post
    Not all header instructions are to do with redirection.....
    mail() function uses headers too, check that your mail function is all correct and that the fields are there - echo them out to see.

    Also check up in the manual about which headers are required.
    I couldnt find anything within the manual about mail() which may suggest a problem. I did however take all the script about mail() out and uploaded it and the page successfully re-directed.

    The mail functions in themselves are working properly because when the page is not re-directing I am sent the mail (and the user is sent the mail)

    So...anyone any ideas how i can get these two re-direct and mail to work together? -or another way of doing the same thing?

    thanks for your help

  6. #6
    SitePoint Evangelist
    Join Date
    May 2007
    Location
    Kent in Uk
    Posts
    538
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi,
    thanks for everyones input. this is one of those problems thats just righted itself on its own

    what a waste of a day....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •