#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    6
    Rep Power
    0

    Quick easy ( I think) help on a contact form (PHP)


    I have a contact page at
    michaelapeterson.com/contactform.php
    The contact works, but the person is supposed to then be redirected to a contact page and that DOESN'T work. . just leaves them on a blank page, all navigation gone.

    Can anyone help? Here is the redirect code (complete code for the page below)
    Code:
    if(isset($_POST['submitted']))
    {
       if($formproc->ProcessForm())
       {
            $formproc->RedirectToURL("index.html");
       }
    }

    Compete code

    Code:
    <head>
    	<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    	
    	<title>Michael A. Peterson</title>
    	
    	<link rel="stylesheet" type="text/css" href="main.css"/>
    	
    	<script type="text/javascript" src="jquery.js"></script>
    	<script type="text/javascript" src="jquery-color.js"></script>
    	<script type="text/javascript" src="main.js"></script>
        <style type="text/css">
    p {font-size:15px; }
    </style>
    </head>
    
    <?PHP
    require_once("./include/fgcontactform.php");
    
    $formproc = new FGContactForm();
    
    
    
    $formproc->AddRecipient('michael@michaelapeterson.com'); 
    $formproc->SetFormRandomKey('CnRrspl1FyEylUj');
    
    
    if(isset($_POST['submitted']))
    {
       if($formproc->ProcessForm())
       {
            $formproc->RedirectToURL("index.html");
       }
    }
    
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
    <head>
          <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
          <title>Contact us</title>
          <link rel="STYLESHEET" type="text/css" href="contact.css" />
          <script type='text/javascript' src='scripts/gen_validatorv31.js'></script>
    </head>
    <body>
    	<div id="Me"P { text-align: center }
    H2 { text-align: center }>
    	
    			
    <center>
    			  <h1><a href="index.html">Michael A. Peterson<BR />
    			  </a>Contact Page</h1></center>
    	<div id="pageWrap">
    		<div id="pageBody">
    			
    		
    			
    			<a class="hoverBtn" href="Notary Services.html">Notary Services</a>
                <a class="hoverBtn" href="Signing Agent.html">Signing Agent</a>
    			<a class="hoverBtn" href="Franchise Consulting.html">Franchise Consulting</a>
    			<a class="hoverBtn" href="contactform.php">Contact Me</a>
    <BR /><BR />
    
    	<div id="Agent">		
    	<p>	To contact me, please either call me at (949) 892-7862, email me at Michael@michaelapeterson.com, or use the form below. <BR /></div>
    </p><br /><div id="form">
    
    <!-- Form Code Start -->
    <form id='contactus' action='<?php echo $formproc->GetSelfScript(); ?>' method='post' accept-charset='UTF-8'>
    <fieldset >
    <legend>Contact Me</legend>
    
    <input type='hidden' name='submitted' id='submitted' value='1'/>
    <input type='hidden' name='<?php echo $formproc->GetFormIDInputName(); ?>' value='<?php echo $formproc->GetFormIDInputValue(); ?>'/>
    <input type='text'  class='spmhidip' name='<?php echo $formproc->GetSpamTrapInputName(); ?>' />
    
    
    <div><span class='error'><?php echo $formproc->GetErrorMessage(); ?></span></div>
    <div class='container'>
    <p>Why would you like to contact me?<select name="myselect">
    <option value="Notary">Mobile Notary</option>
    <option value="Signing">Signing Agent</option>
    <option value="Franchise">Franchise Consulting</option>
    <option value="Other">Other</option>
    </select><br />
        <label for='name' ><p>Your Full Name: </label><br/>
        <input type='text' name='name' id='name' value='<?php echo $formproc->SafeDisplay('name') ?>' maxlength="50" /><br/>
        <span id='contactus_name_errorloc' class='error'></span>
    </div>
    <div class='container'>
        <label for='email' ><p>Email Address:</p></label><br/>
        <input type='text' name='email' id='email' value='<?php echo $formproc->SafeDisplay('email') ?>' maxlength="50" /><br/>
        <span id='contactus_email_errorloc' class='error'></span>
    </div>
    
    <div class='container'>
        <label for='message' ><p>Message:</label><br/>
        <span id='contactus_message_errorloc' class='error'></span>
        <textarea rows="10" cols="50" name='message' id='message'><?php echo $formproc->SafeDisplay('message') ?></textarea>
    </div>
    
    
    <div class='container'>
        <input type='submit' name='Submit' value='Submit' />
    </div>
    
    </fieldset>
    </form>
    
    
    <script type='text/javascript'>
    
        var frmvalidator  = new Validator("contactus");
        frmvalidator.EnableOnPageErrorDisplay();
        frmvalidator.EnableMsgsTogether();
        frmvalidator.addValidation("name","req","Please provide your name");
    
        frmvalidator.addValidation("email","req","Please provide your email address");
    
        frmvalidator.addValidation("email","email","Please provide a valid email address");
    
        frmvalidator.addValidation("message","maxlen=2048","The message is too long!(more than 2KB!)");
    
    // ]]>
    </script>
    
    </body>
    </html>
  2. #2
  3. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,151
    Rep Power
    487
    How about posting the code that's supposed to do the re-direct?
    "For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
    - George Orwell, 1984
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    6
    Rep Power
    0

    That was in the post


    Originally Posted by badger_fruit
    How about posting the code that's supposed to do the re-direct?
    The fact that you asked that makes me think I completely blew it. I THOUGHT what was supposed to do the re-direct was

    Code:
    if(isset($_POST['submitted']))
     {    if($formproc->ProcessForm())    {         $formproc->RedirectToURL("index.html");    } }
    Again, I am not much on PHP, so maybe i completely have this wrong. Thoughts?
  6. #4
  7. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,151
    Rep Power
    487
    Originally Posted by thespasticone
    The fact that you asked that makes me think I completely blew it. I THOUGHT what was supposed to do the re-direct was

    Code:
    if(isset($_POST['submitted']))
     {    if($formproc->ProcessForm())    {         $formproc->RedirectToURL("index.html");    } }
    Again, I am not much on PHP, so maybe i completely have this wrong. Thoughts?
    LOL, not quite, the code

    $formproc->RedirectToURL("index.html");

    Uses the "RedirectToURL" method from the $formproc class.
    It's not a PHP command (I would presume it'll call header() which IS a PHP command).

    I've a feeling that it's not working because header() will only work if there's nothing else on the page before the header() command is called ... hence why we need to see what's actually doing the re-direct so we can say for certain
    "For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
    - George Orwell, 1984
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    6
    Rep Power
    0
    Originally Posted by badger_fruit
    LOL, not quite, the code

    $formproc->RedirectToURL("index.html");

    Uses the "RedirectToURL" method from the $formproc class.
    It's not a PHP command (I would presume it'll call header() which IS a PHP command).

    I've a feeling that it's not working because header() will only work if there's nothing else on the page before the header() command is called ... hence why we need to see what's actually doing the re-direct so we can say for certain
    Got you. . I appreciate your help but am not tracking on what you need. In my top post, though, I did put the code for the entire page. Is there something else I can give you?

    Again, thanks a ton for your time on this!
  10. #6
  11. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,151
    Rep Power
    487
    I think you need to post the code from the file ./include/fgcontactform.php
    "For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
    - George Orwell, 1984
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    6
    Rep Power
    0
    Originally Posted by badger_fruit
    I think you need to post the code from the file ./include/fgcontactform.php

    Gotcha. . . I am using one that was available on the internet

    Code:
    <?PHP
    /*
        Contact Form from HTML Form Guide
    
        This program is free software published under the
        terms of the GNU Lesser General Public License.
    
    This program is distributed in the hope that it will
    be useful - WITHOUT ANY WARRANTY; without even the
    implied warranty of MERCHANTABILITY or FITNESS FOR A
    PARTICULAR PURPOSE.
    
    @copyright html-form-guide.com 2010
    */
    require_once("class.phpmailer.php");
    
    /*
    Interface to Captcha handler
    */
    class FG_CaptchaHandler
    {
        function Validate() { return false;}
        function GetError(){ return '';}
    }
    /*
    FGContactForm is a general purpose contact form class
    It supports Captcha, HTML Emails, sending emails
    conditionally, File atachments and more.
    */
    class FGContactForm
    {
        var $receipients;
        var $errors;
        var $error_message;
        var $name;
        var $email;
        var $message;
        var $from_address;
        var $form_random_key;
        var $conditional_field;
        var $arr_conditional_receipients;
        var $fileupload_fields;
        var $captcha_handler;
    
        var $mailer;
    
        function FGContactForm()
        {
            $this->receipients = array();
            $this->errors = array();
            $this->form_random_key = 'HTgsjhartag';
            $this->conditional_field='';
            $this->arr_conditional_receipients=array();
            $this->fileupload_fields=array();
    
            $this->mailer = new PHPMailer();
            $this->mailer->CharSet = 'utf-8';
        }
    
        function EnableCaptcha($captcha_handler)
        {
            $this->captcha_handler = $captcha_handler;
            session_start();
        }
    
        function AddRecipient($email,$name="")
        {
            $this->mailer->AddAddress($email,$name);
        }
    
        function SetFromAddress($from)
        {
            $this->from_address = $from;
        }
        function SetFormRandomKey($key)
        {
            $this->form_random_key = $key;
        }
        function GetSpamTrapInputName()
        {
            return 'sp'.md5('KHGdnbvsgst'.$this->GetKey());
        }
        function SafeDisplay($value_name)
        {
            if(empty($_POST[$value_name]))
            {
                return'';
            }
            return htmlentities($_POST[$value_name]);
        }
        function GetFormIDInputName()
        {
            $rand = md5('TygshRt'.$this->GetKey());
    
            $rand = substr($rand,0,20);
            return 'id'.$rand;
        }
    
    
        function GetFormIDInputValue()
        {
            return md5('jhgahTsajhg'.$this->GetKey());
        }
    
        function SetConditionalField($field)
        {
            $this->conditional_field = $field;
        }
        function AddConditionalReceipent($value,$email)
        {
            $this->arr_conditional_receipients[$value] =  $email;
        }
    
        function AddFileUploadField($file_field_name,$accepted_types,$max_size)
        {
    
            $this->fileupload_fields[] =
                array("name"=>$file_field_name,
                "file_types"=>$accepted_types,
                "maxsize"=>$max_size);
        }
    
        function ProcessForm()
        {
            if(!isset($_POST['submitted']))
            {
               return false;
            }
            if(!$this->Validate())
            {
                $this->error_message = implode('<br/>',$this->errors);
                return false;
            }
            $this->CollectData();
    
            $ret = $this->SendFormSubmission();
    
            return $ret;
        }
    
        function RedirectToURL($url)
        {
            header("Location: $url");
            exit;
        }
    
        function GetErrorMessage()
        {
            return $this->error_message;
        }
        function GetSelfScript()
        {
            return htmlentities($_SERVER['PHP_SELF']);
        }
    
        function GetName()
        {
            return $this->name;
        }
        function GetEmail()
        {
            return $this->email;
        }
        function GetMessage()
        {
            return htmlentities($this->message,ENT_QUOTES,"UTF-8");
        }
    
    /*--------  Private (Internal) Functions -------- */
    
    
        function SendFormSubmission()
        {
            $this->CollectConditionalReceipients();
    
            $this->mailer->CharSet = 'utf-8';
            
            $this->mailer->Subject = "Contact form submission from $this->name";
    
            $this->mailer->From = $this->GetFromAddress();
    
            $this->mailer->FromName = $this->name;
    
            $this->mailer->AddReplyTo($this->email);
    
            $message = $this->ComposeFormtoEmail();
    
            $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
            $this->mailer->AltBody = @html_entity_decode($textMsg,ENT_QUOTES,"UTF-8");
            $this->mailer->MsgHTML($message);
    
            $this->AttachFiles();
    
            if(!$this->mailer->Send())
            {
                $this->add_error("Failed sending email!");
                return false;
            }
    
            return true;
        }
    
        function CollectConditionalReceipients()
        {
            if(count($this->arr_conditional_receipients)>0 &&
              !empty($this->conditional_field) &&
              !empty($_POST[$this->conditional_field]))
            {
                foreach($this->arr_conditional_receipients as $condn => $rec)
                {
                    if(strcasecmp($condn,$_POST[$this->conditional_field])==0 &&
                    !empty($rec))
                    {
                        $this->AddRecipient($rec);
                    }
                }
            }
        }
    
        /*
        Internal variables, that you donot want to appear in the email
        Add those variables in this array.
        */
        function IsInternalVariable($varname)
        {
            $arr_interanl_vars = array('scaptcha',
                                'submitted',
                                $this->GetSpamTrapInputName(),
                                $this->GetFormIDInputName()
                                );
            if(in_array($varname,$arr_interanl_vars))
            {
                return true;
            }
            return false;
        }
    
        function FormSubmissionToMail()
        {
            $ret_str='';
            foreach($_POST as $key=>$value)
            {
                if(!$this->IsInternalVariable($key))
                {
                    $value = htmlentities($value,ENT_QUOTES,"UTF-8");
                    $value = nl2br($value);
                    $key = ucfirst($key);
                    $ret_str .= "<div class='label'>$key :</div><div class='value'>$value </div>\n";
                }
            }
            foreach($this->fileupload_fields as $upload_field)
            {
                $field_name = $upload_field["name"];
                if(!$this->IsFileUploaded($field_name))
                {
                    continue;
                }        
                
                $filename = basename($_FILES[$field_name]['name']);
    
                $ret_str .= "<div class='label'>File upload '$field_name' :</div><div class='value'>$filename </div>\n";
            }
            return $ret_str;
        }
    
        function ExtraInfoToMail()
        {
            $ret_str='';
    
            $ip = $_SERVER['REMOTE_ADDR'];
            $ret_str = "<div class='label'>IP address of the submitter:</div><div class='value'>$ip</div>\n";
    
            return $ret_str;
        }
    
        function GetMailStyle()
        {
            $retstr = "\n<style>".
            "body,.label,.value { font-family:Arial,Verdana; } ".
            ".label {font-weight:bold; margin-top:5px; font-size:1em; color:#333;} ".
            ".value {margin-bottom:15px;font-size:0.8em;padding-left:5px;} ".
            "</style>\n";
    
            return $retstr;
        }
        function GetHTMLHeaderPart()
        {
             $retstr = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">'."\n".
                       '<html><head><title></title>'.
                       '<meta http-equiv=Content-Type content="text/html; charset=utf-8">';
             $retstr .= $this->GetMailStyle();
             $retstr .= '</head><body>';
             return $retstr;
        }
        function GetHTMLFooterPart()
        {
            $retstr ='</body></html>';
            return $retstr ;
        }
        function ComposeFormtoEmail()
        {
            $header = $this->GetHTMLHeaderPart();
            $formsubmission = $this->FormSubmissionToMail();
            $extra_info = $this->ExtraInfoToMail();
            $footer = $this->GetHTMLFooterPart();
    
            $message = $header."Submission from 'contact us' form:<p>$formsubmission</p><hr/>$extra_info".$footer;
    
            return $message;
        }
    
        function AttachFiles()
        {
            foreach($this->fileupload_fields as $upld_field)
            {
                $field_name = $upld_field["name"];
                if(!$this->IsFileUploaded($field_name))
                {
                    continue;
                }
                
                $filename =basename($_FILES[$field_name]['name']);
    
                $this->mailer->AddAttachment($_FILES[$field_name]["tmp_name"],$filename);
            }
        }
    
        function GetFromAddress()
        {
            if(!empty($this->from_address))
            {
                return $this->from_address;
            }
    
            $host = $_SERVER['SERVER_NAME'];
    
            $from ="nobody@$host";
            return $from;
        }
    
        function Validate()
        {
            $ret = true;
            //security validations
            if(empty($_POST[$this->GetFormIDInputName()]) ||
              $_POST[$this->GetFormIDInputName()] != $this->GetFormIDInputValue() )
            {
                //The proper error is not given intentionally
                $this->add_error("Automated submission prevention: case 1 failed");
                $ret = false;
            }
    
            //This is a hidden input field. Humans won't fill this field.
            if(!empty($_POST[$this->GetSpamTrapInputName()]) )
            {
                //The proper error is not given intentionally
                $this->add_error("Automated submission prevention: case 2 failed");
                $ret = false;
            }
    
            //name validations
            if(empty($_POST['name']))
            {
                $this->add_error("Please provide your name");
                $ret = false;
            }
            else
            if(strlen($_POST['name'])>50)
            {
                $this->add_error("Name is too big!");
                $ret = false;
            }
    
            //email validations
            if(empty($_POST['email']))
            {
                $this->add_error("Please provide your email address");
                $ret = false;
            }
            else
            if(strlen($_POST['email'])>50)
            {
                $this->add_error("Email address is too big!");
                $ret = false;
            }
            else
            if(!$this->validate_email($_POST['email']))
            {
                $this->add_error("Please provide a valid email address");
                $ret = false;
            }
    
            //message validaions
            if(strlen($_POST['message'])>2048)
            {
                $this->add_error("Message is too big!");
                $ret = false;
            }
    
            //captcha validaions
            if(isset($this->captcha_handler))
            {
                if(!$this->captcha_handler->Validate())
                {
                    $this->add_error($this->captcha_handler->GetError());
                    $ret = false;
                }
            }
            //file upload validations
            if(!empty($this->fileupload_fields))
            {
             if(!$this->ValidateFileUploads())
             {
                $ret = false;
             }
            }
            return $ret;
        }
    
        function ValidateFileType($field_name,$valid_filetypes)
        {
            $ret=true;
            $info = pathinfo($_FILES[$field_name]['name']);
            $extn = $info['extension'];
            $extn = strtolower($extn);
    
            $arr_valid_filetypes= explode(',',$valid_filetypes);
            if(!in_array($extn,$arr_valid_filetypes))
            {
                $this->add_error("Valid file types are: $valid_filetypes");
                $ret=false;
            }
            return $ret;
        }
    
        function ValidateFileSize($field_name,$max_size)
        {
            $size_of_uploaded_file =
                    $_FILES[$field_name]["size"]/1024;//size in KBs
            if($size_of_uploaded_file > $max_size)
            {
                $this->add_error("The file is too big. File size should be less than $max_size KB");
                return false;
            }
            return true;
        }
    
        function IsFileUploaded($field_name)
        {
            if(empty($_FILES[$field_name]['name']))
            {
                return false;
            }
            if(!is_uploaded_file($_FILES[$field_name]['tmp_name']))
            {
                return false;
            }
            return true;
        }
        function ValidateFileUploads()
        {
            $ret=true;
            foreach($this->fileupload_fields as $upld_field)
            {
                $field_name = $upld_field["name"];
    
                $valid_filetypes = $upld_field["file_types"];
                
                if(!$this->IsFileUploaded($field_name))
                {
                    continue;
                }
    
                if($_FILES[$field_name]["error"] != 0)
                {
                    $this->add_error("Error in file upload; Error code:".$_FILES[$field_name]["error"]);
                    $ret=false;
                }
    
                if(!empty($valid_filetypes) &&
                 !$this->ValidateFileType($field_name,$valid_filetypes))
                {
                    $ret=false;
                }
    
                if(!empty($upld_field["maxsize"]) &&
                $upld_field["maxsize"]>0)
                {
                    if(!$this->ValidateFileSize($field_name,$upld_field["maxsize"]))
                    {
                        $ret=false;
                    }
                }
    
            }
            return $ret;
        }
    
        function StripSlashes($str)
        {
            if(get_magic_quotes_gpc())
            {
                $str = stripslashes($str);
            }
            return $str;
        }
        /*
        Sanitize() function removes any potential threat from the
        data submitted. Prevents email injections or any other hacker attempts.
        if $remove_nl is true, newline chracters are removed from the input.
        */
        function Sanitize($str,$remove_nl=true)
        {
            $str = $this->StripSlashes($str);
    
            if($remove_nl)
            {
                $injections = array('/(\n+)/i',
                    '/(\r+)/i',
                    '/(\t+)/i',
                    '/(%0A+)/i',
                    '/(%0D+)/i',
                    '/(%08+)/i',
                    '/(%09+)/i'
                    );
                $str = preg_replace($injections,'',$str);
            }
    
            return $str;
        }
    
        /*Collects clean data from the $_POST array and keeps in internal variables.*/
        function CollectData()
        {
            $this->name = $this->Sanitize($_POST['name']);
            $this->email = $this->Sanitize($_POST['email']);
    
            /*newline is OK in the message.*/
            $this->message = $this->StripSlashes($_POST['message']);
        }
    
        function add_error($error)
        {
            array_push($this->errors,$error);
        }
        function validate_email($email)
        {
            return eregi("^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$", $email);
        }
    
        function GetKey()
        {
            return $this->form_random_key.$_SERVER['SERVER_NAME'].$_SERVER['REMOTE_ADDR'];
        }
    
    }
    
    ?>
  14. #8
  15. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,151
    Rep Power
    487
    Hi there
    OK, in that code you see there's a bit that reads:-

    PHP Code:
        function RedirectToURL($url)
        {
            
    header("Location: $url");
            exit;
        } 
    That's called by the line in the earlier code $formproc->RedirectToURL("index.html");

    Now, in theory that "header redirect" as it's called, should work as there's not really a lot more to it then what you see there. The problem of that re-direct method is that it only seems to work if there are no other characters sent to the browser before that command is called - I think (and may need a 2nd pair of eyes on your code to verify this) but I think that your code sends some things to the browser which is stopping the re-direct from working.

    I would suggest moving this block (see below) from where it is now, to the very first line in your script (you may need to wrap it in "<?php" and "?>" tags):

    PHP Code:
    if(isset($_POST['submitted']))
    {
       if(
    $formproc->ProcessForm())
       {
            
    $formproc->RedirectToURL("index.html");
       }

    Let us know how you get on!
    "For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
    - George Orwell, 1984
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    6
    Rep Power
    0
    Originally Posted by badger_fruit
    Hi there
    OK, in that code you see there's a bit that reads:-

    PHP Code:
        function RedirectToURL($url)
        {
            
    header("Location: $url");
            exit;
        } 
    That's called by the line in the earlier code $formproc->RedirectToURL("index.html");

    Now, in theory that "header redirect" as it's called, should work as there's not really a lot more to it then what you see there. The problem of that re-direct method is that it only seems to work if there are no other characters sent to the browser before that command is called - I think (and may need a 2nd pair of eyes on your code to verify this) but I think that your code sends some things to the browser which is stopping the re-direct from working.

    I would suggest moving this block (see below) from where it is now, to the very first line in your script (you may need to wrap it in "<?php" and "?>" tags):

    PHP Code:
    if(isset($_POST['submitted']))
    {
       if(
    $formproc->ProcessForm())
       {
            
    $formproc->RedirectToURL("index.html");
       }

    Let us know how you get on!

    Once again thanks for the help/input. When I moved this line of code up to the top of my contact form script, either wrapped in it's own <> or not, it kills the rest of the form. . The nav shows up, but not of the form does.
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    6
    Rep Power
    0

    Thanks for all your help, problem solved


    2 issues.

    #1 I DID have error reporting, but it was black text on an almost black background. . Didn't see that 'till i was walking away from the computer, and saw it from an angle.

    #2, PHP had to be ABOVE the header. . I think someone was trying to tell me that, but it wasn't sinking in.

    Thanks again for the help.
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    I am using the same pop form..need help with validating checkboxes


    I have added a checkbox:

    <div class='container'>
    <label for='terms_and_conditions' >I have read and agree to the Terms & Conditions.*</label>
    <input type='checkbox' id='Terms and Conditions' name='terms_and_conditions' value='Yes'>
    <span id='contactus_terms_and_conditions_errorloc' class='error'></span>
    <br/>
    </div>

    I have validations at the bottom of the same page like so:

    frmvalidator.addValidation("terms_and_conditions","shouldselchk=yes","Please agree to the Terms and Conditions.");

    My server is ignoring all of validations like the one above, but is responding to the all validations in this file except for the checkbox: include/fgcontactform.php

    I don't know how...I am a newbie too.


    //terms and conditions validations
    if(isset($_POST['terms_and_conditions']))
    {
    $this->add_error("Please agree to the Terms and Conditions");
    $ret = false;
    }


    Can anyone please help? I have been searching for a week.

IMN logo majestic logo threadwatch logo seochat tools logo