Jump to content

Website PHP form Help!


danielford99

Recommended Posts

Hey guys,

 

Its been a while since I have requested help, the last time I did I got sorted on here :)

 

I have created an online quotation form for our customers;

 

http://www.eurocoms.co.uk/free-online-cabling-quotation.htm

 

No matter what I do, once I press submit, I get a blank white screen.

 

We have the exact same form, PHP etc on the Contact Us link that works fine.

 

Here is the PHP code for send_quote_email.php

 

Any help will be greatly appreciated :)

 

 

<?php

if(isset($_POST['email'])) {

 

// EDIT THE 2 LINES BELOW AS REQUIRED

$email_to = "dford@eurocoms.co.uk";

$email_subject = "Eurocoms Quotation Form";

 

 

function died($error) {

// your error code can go here

echo "We are very sorry, but there were error(s) found with the form your submitted. ";

echo "These errors appear below.<br /><br />";

echo $error."<br /><br />";

echo "Please go back and fix these errors.<br /><br />";

die();

}

 

// validation expected data exists

if(!isset($_POST['full_name']) ||

!isset($_POST['company_name']) ||

!isset($_POST['telephone_number']) ||

!isset($_POST['email_address']) ||

!isset($_POST['your_position']) ||

!isset($_POST['business_type']) ||

!isset($_POST['your_location']) ||

!isset($_POST['cable_type']) ||

!isset($_POST['cabinet']) ||

!isset($_POST['roof_fan']) ||

!isset($_POST['pdu']) ||

!isset($_POST['patch_leads']) ||

!isset($_POST['description']) ||

!isset($_POST['single_socket']) ||

!isset($_POST['double_socket']) ||

!isset($_POST['quad_socket']) ||

!isset($_POST['area']) ||

!isset($_POST['feet_metres']) ||

!isset($_POST['floors']) ||

!isset($_POST['buildings']) ||

!isset($_POST['floor_type']) ||

!isset($_POST['floor_covering']) ||

!isset($_POST['ceiling_type']) ||

!isset($_POST['wall_type']) ||

!isset($_POST['containment']) ||

!isset($_POST['loft_space']) ||

!isset($_POST['fibre_required']) ||

!isset($_POST['voice_required']) ||

!isset($_POST['phonesystem_required']) ||

!isset($_POST['electrical_required'])) {

died('We are sorry, but there are items missing from the form your submitted.');

}

 

$full_name = $_POST['full_name']; // required

$company_name = $_POST['company_name']; // required

$telephone_number = $_POST['telephone_number']; // required

$email_address = $_POST['email_address']; // not required

$your_position = $_POST['your_position']; // required

$business_type = $_POST['business_type']; // required

$your_location = $_POST['your_location']; // required

$cable_type = $_POST['cable_type']; // required

$cabinet = $_POST['cabinet']; // required

$roof_fan = $_POST['roof_fan']; // required

$pdu = $_POST['pdu']; // required

$patch_leads = $_POST['patch_leads']; // required

$description = $_POST['description']; // required

$single_socket = $_POST['single_socket']; // required

$double_socket = $_POST['double_socket']; // required

$quad_socket = $_POST['quad_socket']; // required

$area = $_POST['area']; // required

$feet_metres = $_POST['feet_metres']; // required

$floors = $_POST['floors']; // required

$buildings = $_POST['buildings']; // required

$floor_type = $_POST['floor_type']; // required

$floor_covering = $_POST['floor_covering']; // required

$ceiling_type = $_POST['ceiling_type']; // required

$wall_type = $_POST['wall_type']; // required

$containment = $_POST['containment']; // required

$loft_space = $_POST['loft_space']; // required

$fibre_required = $_POST['fibre_required']; // required

$voice_required = $_POST['voice_required']; // required

$phonesystem_required = $_POST['phonesystem_required']; // required

$electrical_required = $_POST['electrical_required']; // required

 

$error_message = "";

$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";

if(!eregi($email_exp,$email_from)) {

$error_message .= 'The email address you entered does not appear to be valid.<br />';

}

$string_exp = "^[a-z .'-]+$";

if(!eregi($string_exp,$full_name)) {

$error_message .= 'The name you entered does not appear to be valid.<br />';

}

if(!eregi($string_exp,$company_name)) {

$error_message .= 'The company you entered does not appear to be valid.<br />';

}

if(strlen($your_position) < 2) {

$error_message .= 'The position you entered do not appear to be valid.<br />';

}

$string_exp = "^[0-9 .-]+$";

if(!eregi($string_exp,$telephone_number)) {

$error_message .= 'The telephone number you entered does not appear to be valid.<br />';

}

if(strlen($error_message) > 0) {

died($error_message);

}

$email_message = "Form details below.\n\n";

 

function clean_string($string) {

$bad = array("content-type","bcc:","to:","cc:","href");

return str_replace($bad,"",$string);

}

 

$email_message .= "First Name: ".clean_string($full_name)."\n";

$email_message .= "Company Name: ".clean_string($company_name)."\n";

$email_message .= "Email: ".clean_string($email_address)."\n";

$email_message .= "Telephone Number: ".clean_string($telephone_number)."\n";

$email_message .= "Position: ".clean_string($your_position)."\n";

$email_message .= "Business Type: ".clean_string($business_type)."\n";

$email_message .= "Location: ".clean_string($your_location)."\n";

$email_message .= "Cable Type: ".clean_string($cable_type)."\n";

$email_message .= "Cabinets: ".clean_string($cabinet)."\n";

$email_message .= "Roof Fan: ".clean_string($roof_fan)."\n";

$email_message .= "PDU's: ".clean_string($pdu)."\n";

$email_message .= "Any Patch Leads: ".clean_string($patch_leads)."\n";

$email_message .= "Work Description: ".clean_string($description)."\n";

$email_message .= "No. Singles: ".clean_string($single_socket)."\n";

$email_message .= "No. Duals: ".clean_string($double_socket)."\n";

$email_message .= "No. Quads: ".clean_string($quad_socket)."\n";

$email_message .= "Area Size: ".clean_string($area)."\n";

$email_message .= "Feet or Metres: ".clean_string($feet_metres)."\n";

$email_message .= "Many Floors: ".clean_string($floors)."\n";

$email_message .= "Buildings: ".clean_string($buildings)."\n";

$email_message .= "Floor Type: ".clean_string($floor_type)."\n";

$email_message .= "Floor Covering: ".clean_string($floor_covering)."\n";

$email_message .= "Ceiling: ".clean_string($ceiling_type)."\n";

$email_message .= "Wall Type: ".clean_string($wall_type)."\n";

$email_message .= "Containment: ".clean_string($containment)."\n";

$email_message .= "Loft: ".clean_string($loft_space)."\n";

$email_message .= "Fibre: ".clean_string($fibre_required)."\n";

$email_message .= "Voice: ".clean_string($voice_required)."\n";

$email_message .= "Phone System: ".clean_string($phonesystem_required)."\n";

$email_message .= "Electrical: ".clean_string($electrical_required)."\n";

 

 

// create email headers

$headers = 'From: '.$email_from."\r\n".

'Reply-To: '.$email_from."\r\n" .

'X-Mailer: PHP/' . phpversion();

@mail($email_to, $email_subject, $email_message, $headers);

?>

 

<!-- include your own success html here -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

 

<html>

<head>

 

<title>Free Online Structured Cabling Installation Requests by Eurocoms of South Yorkshire</title>

 

<meta name="url" content="www.eurocoms.co.uk" />

 

<meta name="revisit" content="1 days" />

 

<meta name="description" content=

 

"Free Online Structured Cabling Installation Requests by Eurocoms of South Yorkshire" />

 

<meta name="keywords" content=

 

"Quotations for Structured Cabling, Fibre Optics, Telephone Systems and Electrical Works in the UK" />

 

<meta name="robots" content="index, follow" />

 

<meta name="copyright" content=

 

"Copyright © eurocoms. All Rights Reserved." />

 

<meta name="author" content="Eurocoms Ltd" />

 

 

<link rel="stylesheet" type="text/css" href="eurocoms.css" />

<STYLE TYPE="text/css"><!--

@import url("thankyou.css");

--></STYLE>

 

</head>

<body>

<div id="testamonials"><script src="testamonials2.js"

language="javascript"

type="text/javascript"></script>

</div>

<div id="container">

 

<div id="top"><img src="top-left.jpg" alt="#" id="top-left" /><img src="logo.jpg" alt="Eurocoms Ltd" /><img src="top-right.jpg" alt="#" id="top-right" /></div>

<div id="top-menu"><a href="about-us.htm" class="top-menu">About Us</a> <img src="bullet.gif" alt="bullet" /><a href="contact-us.htm" class="top-menu">Contact Us</a><img src="bullet.gif" alt="bullet" /><a href="our-aim.htm" class="top-menu">Our Aim</a><img src="bullet.gif" alt="bullet" /><a href="standards.htm" class="top-menu">Standards</a> <img src="bullet.gif" alt="bullet" /> <a href="warranty.htm" class="top-menu">Warranty</a> </div>

 

<br />

 

<div id="services"><div id="services-title">Our Services</div>

<div id="services-contents">

<a href="free-online-cabling-quotation.htm" class="services-contents">Free Online Quotation</a>

<a href="design-and-installation.htm" class="services-contents">Design & Installation</a>

<a href="structured-cabling.htm" class="services-contents">Structured Cabling</a>

<a href="fibre-optics.htm" class="services-contents">Fibre Optic Cabling</a>

<a href="telephone_number-systems.htm" class="services-contents">telephone_number Systems</a>

<a href="wi-fi-hotspots.htm" class="services-contents">Wireless Networking</a>

<a href="tv-distribution.htm" class="services-contents">TV Distribution</a>

<a href="Business-Broadband.htm" class="services-contents">Business Broadband</a>

<a href="maintenance.htm" class="services-contents">Maintenance</a>

<a href="access-control.htm" class="services-contents">Access Control</a>

<a href="door-entry-systems.htm" class="services-contents">Door Entry Systems</a>

<a href="CCTV.htm" class="services-contents">CCTV Systems</a>

<a href="displaysolutions.htm" class="services-contents">Audio & Visual</a></div>

</div>

 

<div id="patch"><img src="patch-left.jpg" alt="#" /></div>

 

<div id="content">

<div id="text-trans">

<div id="text"><div id="nav"><a href="index.htm">[Home]</a></div>

<br />

<br />

<img src="thankyou-right.gif" class="right" />

<div id="text-trans">

<div id="text"><span class="title">Thank you!

</span></div>

</div>

<div id="text-trans">

<div id="text">

<p>Your quotation request has been received and we aim to respond within 8 hours.</p>

<p>If your enquery requires an urgent response, please call 0844 3577 678, alternatively you can call 07985 590 933 (24/7).</p>

<p> Please use the menus or the <a href="index.htm">[home]</a> button

to navigate around the site.</p>

<p> </p>

<p> </p>

<p> </p>

</div>

</div>

<span class="nobold"></span></div>

</div>

<br /><br />

 

<br />

 

<div id="footer"><a href="site-terms-and-conditions.htm">Site Terms & Conditions</a> | <a href="access-policy.htm">Access Policy</a> | <a href="#">Text Mode</a> | Copyright 2012 Eurocoms (UK) Ltd| Registered in England: 07879489<br />

</div><br />

 

</div>

 

 

<div id="virus-alert"><div id="virus-alert-title">Latest Virus Alerts</div><div id="virus-alert-content">

<script language="JavaScript" src="http://www.eurocoms.co.uk/feed/feed2js.php?src=http%3A%2F%2Ffeeds.sophos.com%2Fen%2Frss2_0-sophos-latest-viruses.xml&num=5&date=y&tz=0&targ=y&html=a" type="text/javascript"></script>

 

<noscript>

<a href="http://www.eurocoms.co.uk/feed/feed2js.php?src=http%3A%2F%2Ffeeds.sophos.com%2Fen%2Frss2_0-sophos-latest-viruses.xml&num=5&date=y&tz=0&targ=y&html=y">View RSS feed</a>

</noscript>

 

</div></div>

 

<br />

<div id="price-promise">

<div id="price-promise-title">Latest Offers </div>

<div id="price-promise-content">

<p><a href="http://www.eurocoms.co.uk/structured-cabling.htm">Cat5e Cabling Systems from £20 per outlet</a></p>

<p><a href="http://www.eurocoms.co.uk/structured-cabling.htm">Cat6 Cabling Systems from £25 per outlet</a></p>

<p>Call Sales Now:<br />

0844 3577 678 </p>

</div>

</div>

</div>

 

</body>

</html>

 

<?

}

?>

Link to comment
Share on other sites

Are you getting the form results through on email?

 

If you're getting a blank page after hitting submit, but getting the form result through, it must be the part of the script with the custom HTML to display after.

 

Is it bringing the style sheets in properly? Are the CSS files in the right place relative to the PHP script?

 

I've not done this sort of thing for a while, but....

 

<link rel="stylesheet" type="text/css" href="eurocoms.css" />

<STYLE TYPE="text/css"><!--

@import url("thankyou.css");

--></STYLE>

 

....could there be any sort of conflict here between eurocoms.css and thankyou.css?

 

Good luck :thumbsup:

Link to comment
Share on other sites

Hi,

 

There is no error message! I click submit and the page just turns white?

 

Any ideas?

 

Thanks

 

The error message should be in your web server's error log. You can change php.ini settings to display them on screen while you're developing - it's just a small security risk to have that turned on for public websites.

 

You're working blind with no error message. You can't expect a solution from just posting a large code snippet on a forum, unless there's some glaring error.

 

mj.scuba, that part isn't php, this sounds like a php error, so it can't possibly be that.

 

NamelessRob might have found the glaring error... It looks like the 2nd line & the last 3 lines should be deleted altogether though, rather than just altered.

 

delete the second line...

if(isset($_POST['email'])) {

and also delete the last 3 lines...

<?
}
?>

 

That's totally unnecessary & broken, the correct (looking) code to do that job appears a few lines below that.

You wouldn't actually get an error message for that, it just skips the whole thing & does nothing if a non-existent field doesn't exist.

 

There are also some errors in your free-online-cabling-quotation.htm - <input tyoe="text" should be type.

Edited by anywebsite
Link to comment
Share on other sites

There won't be an error, the line I've quoted skips the script (including the html) if no variable 'email' is passed from the form (to prevent search-bots overloading the system).

 

As the html form doesn't contain a form input 'email', but rather 'email_address', the script jumps right to the end - exactly as it's been told to.

 

 

 

Edit - posted before I saw anywebsite's edit

Edited by NamelessRob
Response to previous post's edit
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.