Jump to content

blank page upon submission of a form


svgmx5

Recommended Posts

I hope someone here can help me out again. I've got this email form code, that verifies, pretty much everything. The form is working in Chrome and Firefox only, it does not work in IE or safari. Not sure what i'm doing wrong at all. I've looked over the code several times, and i can't come up with an idea on why this is doing it. 

 

If anyone can help me i would gladly appreciate it!

 

I'm using the IE 8 and Safari 4. And it works in Chrome and Firefox 3

 

Heres the code that process the form. Keep in mind the form and process script are in the same page.

 

process:

<?php
	if(getenv(HTTP_X_FORWARDED_FOR)){
		$pipaddress = getenv(HTTP_X_FORWARDED_FOR);
		$ipaddress = getenv(REMOTE_ADDR);
			$ip = "".$pipaddress." (via $ipaddress)";
	}else{
		$ipaddress = getenv(REMOTE_ADDR);
			$ip =  " $ipaddress";
	}
?>
    <?php
	if(isset($_POST['singup']) && !empty($_POST['singup'])){//makes sure the form was submitted
		$secretQ = $_POST['question'];
		$answer= '4';
		if(empty($secretQ)){
			//if user left the question field empty let them know
			$warning = '

			 	<p class="warning"><img src="warningIco.png" width="14" height="15" alt="warning" /> You forgot to enter the answer!</p>

			';

		}elseif($secretQ==$answer){//otherwise if answer and question match then post the remaining variables
			$first_name = $_POST['fname'];
			$last_name = $_POST['lname'];
			$phone = $_POST['phone'];
			$zip = $_POST['zip'];
			$email = $_POST['email'];
			$foundus = $_POST['heard'];
			$message = $_POST['message'];
			$ipaddress = $_POST['ip'];

			//verifies Email Address
			if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){ 
				//if invalid let the user know to use a valid email address
				$emailValid =  '

				<p class="warning"><img src="warningIco.png" width="14" height="15" alt="warning" /> Please type a valid email</p>

				';
			}elseif(!preg_match("/^(?:1(?:[. -])?)?(?:\((?=\d{3}\)))?([2-9]\d{2})(??<=\(\d{3})\))? ?(??<=\d{3})[.-])?([2-9]\d{2})[. -]?(\d{4})(?: (?i:ext)\.? ?(\d{1,5}))?$/", $phone)){//verify phone number
				//if phone format des not match 
				$phoneValid = '

				<p class="warning"><img src="warningIco.png" width="14" height="15" alt="warning" /> Phone Number Format invalid</p>

				';
			}elseif(!preg_match("/^([0-9]{5})(-[0-9]{4})?$/i",$zip)){//verify taht zip code is 5 digits
				//if zip code is not 5 digits 
				$validzip = '

				<p class="warning"><img src="warningIco.png" width="14" height="15" alt="warning" /> Zip Code must be 5 digits long!</p>

				';
			}else{
				//if valid start construction of email body
				$to = '[email protected]';//Insert the email address the contents of the form will be sent to
				$from = 'From: '.$email.' ';// The users Email address
				$subject = 'New Inquiry Regarding a Free Membership'; //What the email is about
				$body = '

				The following has been sent regarding a free membership from IP Address '.$ipaddress.':

				First Name: '.$first_name .'
				Last Name: '.$last_name.'
				Phone Number: '.$phone.'
				Zip Code: '.$zip.'
				Email Address: '.$email.'
				How you Hear from Us: '.$foundus.'
				Your Goals: '.$message.'

				';
				//start the content for the reply email
				$to2 = ''.$email.'';
				$from2 = '[email protected]';
				$subject2 = 'Your Emal to American Boxing';
				$body2 = '

				Your email regarding your free membership has been recieved. Below is a link to access your free membership

				Link to the cupon

				';
				//if everyting is good, then send the email and reply email
				$send = mail($to, $subject, $body, $from);
				$reply = mail($to2, $subject2, $body2, $from2);

				if($send){
					echo'


							<p>Thanks for your interest in training with us!<br/>
							Your FREE pass will be sent to your email address provided</p>
							<p>Fell free to call us with any questions<br/>
							111-111-1111</p>
							<p>Have a Great Day!</p>


					';
				}else{
					//othersise let the user know an error occured and to contact directly
					echo'<span class="warning"><img src="warningIco.png" alt="warning" border="0"/>an Internal error ocurred, that prevented our form from being succesfully sent</span>';
				}
			}//end of else statement that verifies all required fields
		//eof eif Statement	 that verifies the secret question with the answer		
		}else{
			//if secret question is invalid then let the user know. 
			$warning = '

			<p class="warning"><img src="warningIco.png" width="14" height="15" alt="warning" /> The answer you entered is wrong!</p>

			';
		}//enf of else statement
	}else{//shows the form

 

and here is the contiuning script that shows the form

 

echo'
<div class="topTxtForm">
        <div class="introTxt">
            <p>Win a FREE MEMBERSHIP NOW!<br/>
            By filling out the form belo you will<br/>
            automatically recieve a free class pass<br/>
            and be entered to win a FREE Membership!
            </p>
            <p><span>1Pass Per person, Local Residents Only</span></p>
        </div>
    </div>
    <div id="mainForm">
    <form method="post" action="form2.php">
    	<input type="hidden" name="ip" value="$ip"/>
        <div class="inputBox">
            <p class="label">First Name:</p>
            <div class="inputBoxBg">
              <input type="text" name="fname" class="inputMainBox" />
            </div>
        </div>
        <div class="inputBox">
            <p class="label">Last Name:</p>
            <div class="inputBoxBg">
                <input type="text" name="lname" class="inputMainBox" />
            </div>
        </div>
        <div class="inputBoxRequired">
            <p class="label">Phone:</p>
            <div class="inputBoxBg">
                <input type="text" name="phone" class="inputMainBox" />
            </div>';?>
		<?php 
			if(isset($phoneValid)){ // Check if $msg is not empty
				echo ' '.$phoneValid.' '; // Display our message and add a div around it with the class statusmsg
			}else{
				echo '<p class="required">*Valid Phone Number Required</p>';
			}
		?>
	<?php echo'
        </div>
        <div class="inputBoxRequired">
            <p class="label">Zip Code:</p>
            <div class="inputBoxBg">
                <input type="text" name="zip" class="inputMainBox" />
            </div>';?>
            <?php 
			if(isset($validzip)){ // Check if $msg is not empty
				echo ' '.$validzip.' '; // Display our message and add a div around it with the class statusmsg
			}else{
				echo '<p class="required">*Zip Code Required</p>';
			}
		?>
	<?php echo'
        </div>
        <div class="inputBoxRequired">
            <p class="label">Email:</p>
            <div class="inputBoxBg">
                <input type="text" name="email" class="inputMainBox" />
            </div>';?>
            <?php 
			if(isset($emailValid)){ // Check if $msg is not empty
				echo ' '.$emailValid.' '; // Display our message and add a div around it with the class statusmsg
			}else{
				echo '<p class="required">*Valid Email Required!</p>';
			}
		?>
	<?php echo'
        </div>
        <div class="selectInputBox">
        	<p class="label">How Did You Hear about American Boxing?:</p>
            	<select name="heard" class="dropDownMen">
                	<option name="choose">Select One</option>
				<option name="flyers">Flyers</option>
				<option name="wom">Word of Mouth</option>
				<option name="google">Google</option>
				<option name="driveby">Drive By</option>
				<option name="yahoo">Yahoo</option>
				<option name="facebook">Facebook</option>
				<option name="twitter">Twitter</option>
				<option name="StreetSign">Street Sign</option>
				<option name="otherSE">Other Search Engine</option>
			</select>
        </div>
        <div class="inputBoxRequired">
            <p class="label">Whats 2 + 2:</p>
            <div class="inputBoxBg">
                <input type="text" name="question" class="inputMainBox" />
            </div>';?>
            <?php 
			if(isset($warning)){ // Check if $msg is not empty
				echo ' '.$warning.' '; // Display our message and add a div around it with the class statusmsg
			}
		?>
	<?php echo'
        </div>
        <div class="textAreaInput">
        	<p class="label">Tell us your goals:</p>
            <p class="maxTxtWarning">Max 200 Words</p>
            <div class="textAreaBgBox">
              <textarea name="message" cols="50" rows="8" class="textareaInputBox"></textarea>
            </div>
        </div>
        <div class="submitBtnInput">
        	<div class="submitBtnBg">
            	<input type="submit" name="singup" value="Sign Up" />
            </div>
        </div>
    </form>
    </div>'
;
}
?>

 

Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/180390-blank-page-upon-submission-of-a-form/
Share on other sites

Considering the fact that php is parsed on the server long before it even gets to a browser I doubt your issue is related to php at all.

 

Still, you should post your question in the relative board and probably describe what 'not working' actually means while doing so.

okay so i think I've located the issue. I do get a blank page on every browser every time i just press the submit button. Instead of showing me a text that reads, you forgot to fill out your email address, i get blank page

 

can anyone help me?

Can anyone help me make that script work properly?. I want the form to show if the form hasn't been processed, but once its processed, i want it to just echo the thank you text.

 

Right now it does work, however i have verification on email, question, zip and phone, if someone does not input a field and proccess it, the form just goes blank. I don't get an error text like "forgot to input zip.." instead it goes blank?

 

Can anyone help me figure out what i can do to fix it?

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.