Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP Contact form

Featured Replies

Hi,

Could anyone suggest a reason my contact form won't work? I think its something to do with my PHP Script...

 

 

<?php

$contact_name = $_POST['name'];

$contact_email = $_POST['email'];

$contact_subject = $_POST['subject'];

$contact_message = $_POST['message'];

 

if( $contact_name == true )

{

$sender = $contact_email;

$receiver = "sales@styledwebdesign.co.uk";

$client_ip = $_SERVER['REMOTE_ADDR'];

$email_body = "Name: $contact_name \nEmail: $sender \nSubject: $contact_subject \nMessage: $contact_message \nIP: $client_ip \nFlash Charles Marsh Styled;

$extra = "From: $sender\r\n" . "Reply-To: $sender \r\n" . "X-Mailer: PHP/" . phpversion();

 

if( mail( $receiver, "Flash Contact Form - $subject", $email_body, $extra ) )

{

echo "success=yes";

}

else

{

echo "success=no";

}

}

?>

 

Any Ideas?

When the script gets executed there is nothing to set the condition on what should happen when the submit/send button is set...

 

so start with:

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


}

 

 

lose this line...no point in having it:

 if( $contact_name == true )

 

If you want some basic validation you can try :

 

if (empty($_POST['name']) || empty($_POST['email']) || empty($_POST['message'])) { $error_msg ='u suck'  } else { //send the form script }

so start with:

if (isset($_POST['submit'])) {
}

Or, even better...

 

if ($_SERVER['REQUEST_METHOD'] == "POST") {

}

 

I used to check if submit had been POSTed, but in IE6 (I think, off the top of my head), if you tab through a form and hit enter to submit it doesn't send submit as valid POST data.

  • Author
Or, even better...

 

html {
height: 100%;

}
body {
padding-left: 30px;
margin-left: 30px;
background: url(images/bg2.gif) #202020 repeat-y;
margin: 0px;
height: 100%;
color: #cccccc;
font-size:11px;
font-family: "arial";
overflow: scroll;
}

#container {
text-align: left;
vertical-align: bottom;
}
#header {
width: 965px;
height: 210px;
background: url(images/hbg.gif) no-repeat;
}

#content {
width: 965px;
}

#footer {
width: 965px;
height: 150px;
background: url(images/fbg.jpg) no-repeat;
color: #ffffff;
font-size:10px;
font-family: "trebuchet MS";
}
#footernote {
float: right;
text-align: right;
height: 30px;
margin-right: 80px;
margin-top: 110px;
width: 400px;
}

#title {
float: left;
width: 300px;
height: 65px;
margin-left: 20px;
color: #ffffff;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
}

#title a:link {
color: #ff009a;
font-family: "Trebuchet ms";
font-size: 30px;
text-decoration: none;
}
#title a:visited {
color: #ff009a;
font-family: "Trebuchet ms";
font-size: 30px;
text-decoration: none;
}
#title a:hover {
color: #ff009a;
font-family: "Trebuchet ms";
font-size: 30px;
text-decoration: underline;
}

#headerright {
float: right;
width: 450px;
height: 210px;
}
#headerleft {
float: left;
width: 480px;
height: 210px;
}
#search {
float: right;
width: 250px;
height: 30px;
margin-top: 170px;
margin-right: 70px;
text-align: right;
}

.textarea {
border: 1px solid #ffffff;
color: #ffffff;
font-size: 10px;
font-family: verdana;
padding: 4px;
background: #ff009a;
}
.submitcomment {
 width: 119px;
 height: 27px;
 margin: 0px;
 padding: 0px;
 border: 0px;
 background: transparent url(images/submitcomment.gif) no-repeat center top;
 text-indent: -1000em;
 cursor: pointer; /* hand-shaped cursor */
 cursor: hand; /* for IE 5.x */
}

#comment-1 {
 margin: 0px;
 padding: 0px;
}

#comment-2 {
 margin: 0px;
   padding: 0px;
 background: #343434;
}
#center {
width: 470px;
float: left;
}
#sidebar {
float: right;
width: 485px;

}
#left {

float: left;
width: 240px;
border-left: 1px solid #ff009a;
list-style: none;
}

#left p{

margin:10px;
}

#left img { 
   float: left; 
   margin: 5px; 
}



#right {
float: right;
width: 240px;
border-left: 1px solid #ff009a;
}


a:link {
color: #ff009a;
text-decoration: none;
}
a:visited {
color: #ff009a;
text-decoration: none;

}
a:hover {
color: #ff009a;
text-decoration: underline;

}

.meta {
padding-left: 10px;
padding-right: 10px;
background: url(images/meta.gif);
line-height: 30px;
}

blockquote {
border-left: 4px solid #ff009a;
color: #ffffff;
}
blockquote p {
margin: 5px;
}

h1 {
padding-left: 10px;
display:block;
margin: 0px;
font-family: "trebuchet ms";
font-size: 20px;

}

h1 a:link {
font-family: "trebuchet ms";
font-size: 20px;
text-decoration: none;
}
h1 a:visited {
font-family: "trebuchet ms";
font-size: 20px;
text-decoration: none;
}
h1 a:hover {
font-family: "trebuchet ms";
font-size: 20px;
text-decoration: underline;
}

h2 {
font-family: "trebuchet ms";
font-size: 18px;
width: 213px;
height: 37px;
line-height: 37px;
background: url(images/h2.gif) no-repeat;
padding-left: 15px;
padding-right: 10px;
list-style-image: none;
font-weight: lighter;
}

#left li {
list-style-image: url(images/b1.gif) ;
line-height: 14px;
margin-left: 45px;
}
#left ul {
margin-left: 5px;
padding: 0px;
}
.page_item li {
list-style-image: url(images/b3.gif) ;
margin-left: 15px;
padding: 0px;
}

#wp-calendar {
text-align: center;
padding-left: 20px;
}

::-moz-selection{
background:#ff009a;
color:#ffffff;
}

::selection {
background:#ff009a;
color:#ffffff;
}

code::-moz-selection {
background: #ff009a;
}

code::selection {
background: #ff009a;
}

#linkcat-1 ul {
list-style-image: url(images/b4.gif) ;
margin-left: 40px;
padding: 0px;
line-height: 14px;
}

.categories {
line-height: 18px;
list-style: none;
margin-left: 10px;
padding: 0px;
}

.categories ul {
list-style: none;
margin: 0px;
padding: 0px;
}

.categories a:link {
font-family: tahoma;
padding-left: 25px;
display:block;
width: 200px;
color: #ffffff;
background: url(images/menu1.gif) no-repeat;
}
.categories a:visited {
padding-left: 25px;
display:block;
width: 200px;
color: #ffffff;
background: url(images/menu1.gif) no-repeat;
}
.categories a:hover {
background: url(images/menu1.gif) no-repeat;
background-position: 0px -18px;
}

.children  a:link {
font-family: tahoma;
padding-left: 25px;
display:block;
color: #ffffff;
background: url(images/menu2.gif) no-repeat;
}
.children  a:visited {
padding-left: 25px;
display:block;
color: #ffffff;
background: url(images/menu2.gif) no-repeat;
}
.children a:hover {
background: url(images/menu2.gif) no-repeat;
background-position: 0px -18px;
}

.archives {
display: block;
line-height: 18px;
list-style: none;
margin-left: 10px;
padding: 0px;

}
.archives ul {
list-style: none;
margin: 0px;
padding: 0px;
}
.archives li {
list-style: none;
margin: 0px;
padding: 0px;
}

.archives a:link {
width: 200px;
font-family: tahoma;
padding-left: 25px;
display:block;
color: #ffffff;
background: url(images/menu3.gif) no-repeat;
}
.archives a:visited {
width: 200px;
padding-left: 25px;
display:block;
color: #ffffff;
background: url(images/menu3.gif) no-repeat;
}
.archives a:hover {
width: 200px;
background: url(images/menu3.gif) no-repeat;
background-position: 0px -18px;
text-align: center;
}


.metaa {
text-align: right;
line-height: 18px;
list-style: none;
margin-right: 10px;
padding: 0px;
}

#feed {
width: 65px;
height: 65px;
float: right;
margin-top: 34px;
}

#post {
margin: 0px;
padding: 0px;
}

.storycontent {
padding-left:5px;
margin-left:5px;
padding-right:5px;
margin-right:5px;
}

#bullet1 li {
list-style-image: url(images/b1.gif) ;
line-height: 14px;
margin-left: 45px;
}
#bullet1 ul {
margin-left: 5px;
padding: 0px;
}

#bullet2 li {
list-style-image: url(images/b2.gif) ;
line-height: 14px;
margin-left: 45px;
}
#bullet2 ul {
margin-left: 5px;
padding: 0px;
}

#bullet3 li {
list-style-image: url(images/b3.gif) ;
line-height: 14px;
margin-left: 45px;
}
#bullet3 ul {
margin-left: 5px;
padding: 0px;
}

#bullet4 li {
list-style-image: url(images/b4.gif) ;
line-height: 14px;
margin-left: 45px;
}
#bullet4 ul {
margin-left: 5px;
padding: 0px;
}
#bullet5 li {
list-style-image: url(images/b5.gif) ;
line-height: 14px;
margin-left: 45px;
}
#bullet5 ul {
margin-left: 5px;
padding: 0px;
}

 

 

html

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Styled Web Design</title>
   <link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>


<div id="container">
<div id="header">
<div id="headerleft">
 	 <div id="title">
 	   <p><a href="index.html">Styled Web Design</a><br/></p>
 	   </div>
</div>

<div id="headerright">
	<div id="flickr"></div> 
		</div>
</div>

<div id="content">
<div id="center">

<div class="post">
 <h1><a href="#">About Styled...</a></h1>
<div class="meta"></div>
<div class="storycontent">
  <p> Styled designers are experienced, award winning, website designers who plan, design, develop and deliver custom-made, professional, business websites that give an outstanding return on investment.</p>
  <p>From consultation to realisation, Styleds intelligent web design process has a proven track record to deliver business grade websites , on time and on budget. At consultation, we seek to understand your business; its objectives, ethos and brand. We learn what needs to be acheived, help identify the target market and consider how your website may need to be updated in the future as your company grows. 
</p>
</div> 

	 <h1>Previous Work<h1>
     <div class="meta">Here are just some of our previous designs</div>

<div class="storycontent">
  <p align="center"><a href="images/Untitled-1.jpg"><img src="images/Thumnails.gif" width="100" height="87" /></a><a href="images/GlamourLogoOne copy.jpg"><em><img src="images/GlamourLogoOne copy.jpg" width="100" height="87" /></em></a><a href="images/Sunnyleaf.jpg"><img src="images/Leaf.jpg" width="100" height="87" /></a></p>
  <p> </p>
</div> 

</div>	
</div>

<div id="sidebar">
	<div id="left">
		<h2>Services</h2>
	  <p>A website logo design is one of the most important factors with corporate identity and your branding. Our graphic designers can produce graphical illustrations to your requirements and create a unique business logo for your website.
.</p>
		<p>Content management is essential to ensure that your website does not look outdated, and therefore will not make your business look like it is behind the times. A Content Management System allows for a website to be managed without the need of a web designer or developer to make changes. </p>
		<p>We also design Complete Flash websites featuring dynamic content, animations, intros, sound effects and original graphics.</p>
		<p> </p>

		<h2>More Styled </h2>
	  <div id="bullet1">
		<ul>
		  <li><a href="flash.html">Enter our Flash Site</a></li>
	      <li>See example galleries</li>
		  <li>Free downloads</li>
		</ul>
      </div>
	   	<div id="bullet2"></div>
	  <div id="bullet3"></div>
	  <div id="bullet4"></div>
	  <div id="bullet5"></div>

  </div>
	<div id="right">

		<h2>News</h2>

		<ul class="categories">
		  <li>Coming Soon...</li>
		</ul>


	  <h2>Contact Us</h2>

		<ul class="archives">
		  <p>Please contact us for a free no obligation quote</p>
		  <p align="center">Call - 07880651454 </p>
		  <p align="center">Fax- 0871 559 3886</p>
		  <p align="center"> sales@styledwebdesign.co.uk</p>
		  <p align="center">Or use our<a href="contactus.html">Contact Form</a></p>
		  <li></li>
		</ul>

  </div>
</div>


</div>	

<div style="clear: both"><br /></div>

<div id="footer">
<div id="footernote">

Design by <a href="contactushtml.html" title="Webdesigner">Styled Web Design</a>
</div>
</div>


</div>
</body>
</html>

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.