View Full Version : quick easy ( I think) help on a contact form

10-23-2012, 09:25 PM
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.

I am putting the whole code below, but here is the redirect code:


and the whole code:

<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; }


$formproc = new FGContactForm();



<!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">
<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>
<div id="Me"P { text-align: center }
H2 { text-align: 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 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 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 class='container'>
<input type='submit' name='Submit' value='Submit' />


<script type='text/javascript'>

var frmvalidator = new Validator("contactus");
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!)");

// ]]>


10-24-2012, 12:11 AM
Nothing showing on this thread?

10-24-2012, 01:06 AM

10-24-2012, 01:45 AM
Very. If I hit reply I got an invalid link message yet the quick reply works ok :confused:

10-24-2012, 02:19 AM
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:

ini_set('display_errors', 1);

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.

Extra weird. It shows here I approved this thread about 5 hours ago, yet it was listed as moderator approval again after.

10-24-2012, 04:56 PM
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!

10-24-2012, 05:07 PM
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