Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    quick easy ( I think) help on a contact form

    I have created a contact form on my site (viewable at michaelapeterson.com/contactform.php and code below). It works, but the redirect upon submission doesn't. It stays on the same URL, rather than redirecting, and just shows a blank page.

    THANKS FOR ANY HELP!
    I am putting the whole code below, but here is the redirect code:
    Code:
    if(isset($_POST['submitted']))
    {
       if($formproc->ProcessForm())
       {
            $formproc->RedirectToURL("index.html");
       }
    }
    and the whole 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>
    Last edited by thespasticone; 10-23-2012 at 11:44 PM.

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,476
    Thanks
    63
    Thanked 538 Times in 525 Posts
    Nothing showing on this thread?
    I can't really think of anything to write here now...

  • #3
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    Weird

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,476
    Thanks
    63
    Thanked 538 Times in 525 Posts
    Very. If I hit reply I got an invalid link message yet the quick reply works ok
    I can't really think of anything to write here now...

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Its flagged under moderation. You shouldn't be able to see a thread at all when this happens though, so that is quite unusual.

    Okay, so for the OP then, if it shows blank, then this indicates either you have no output, or that the script has failed and no error reporting is enabled. Given you have HTML output here, a white page indicates that you have a fatal error.
    Enable your error reporting:
    PHP Code:
    ini_set('display_errors'1);
    error_reporting(E_ALL); 
    Now, without output buffering, the redirection (assuming it uses headers) is invalid. You cannot push a header after content, and HTML has been provided before the redirect call. The assembling if the HTML is also incorrect, there is a head before an html or body block, and then another head within that html block. You cannot do this. PHP itself won't care a thing about that, but I don't know how well a browser will take to having the output that malformed.


    Edit:
    Extra weird. It shows here I approved this thread about 5 hours ago, yet it was listed as moderator approval again after.
    Last edited by Fou-Lu; 10-24-2012 at 03:28 AM.

  • #6
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Not much of a PHP guy

    I am not sure where I put that code to enable errors. I know that almost all contact pages lead you to somewhere else (even if it looks like its the same screen) after you hit submit. . Am I missing something in my code to accomplish that?

    Thanks for the help!

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Quote Originally Posted by thespasticone View Post
    I am not sure where I put that code to enable errors. I know that almost all contact pages lead you to somewhere else (even if it looks like its the same screen) after you hit submit. . Am I missing something in my code to accomplish that?

    Thanks for the help!
    We haven't a clue. You are using a custom object here, so you need to evaluate what that redirection function does.
    Assuming it does push a header redirect, then without output buffering you cannot have output before that call.

    Error reporting can be set on the first lines of your PHP script. So put it right after <?php


  •  

    Tags for this Thread

    Posting Permissions

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