Log in

View Full Version : What is wrong with this?



lcot
10-05-2010, 05:14 PM
what is wrong with this?...


<?php
if (isset($_POST['imageField']) || isset($_POST['imageField_x']))
{
$name = $_POST['name'];
$email = trim($_POST['email']);
$artist = $_POST['artist'];
$subject = $_POST['subject'];
$message = $_POST['message'];
}

$form = "<form method=\"post\" action=\"test.php\" id=\"contactform\">
<ol>
<li>
<label for=\"name\">First Name <span class=\"required\">*</span></label>
<input id=\"name\" name=\"name\" class=\"text\" value=\"$name\"/>
</li>
<li>
<label for=\"email\">Your email <span class=\"required\">*</span></label>
<input id=\"email\" name=\"email\" class=\"text\" value=\"$email\"/>
</li>
<li>
<label for=\"artist\">Band/Artist Name</label>
<input id=\"artist\" name=\"artist\" class=\"text\" value=\"$artist\">
</li>
<li>
<label for=\"subject\">Subject<span class=\"required\">*</span></label>
<input id=\"subject\" name=\"subject\" class=\"text\" value=\"$subject\">
</li>
<li>
<label for=\"message\">Message <span class=\"required\">*</span></label>
<textarea id=\"message\" name=\"message\" class=\"text\" rows=\"6\" cols=\"50\">$message</textarea>
</li>
<li class=\"buttons\">
<input name=\"imageField\" id=\"imageField\" src=\"images/send.jpg\" class=\"send\" type=\"image\">
<div class=\"clr\"></div>
</li>
</ol>
</form>";

if (isset($_POST['imageField']) || isset($_POST['imageField_x']))
{
$emailSubject = 'Basement Studio Web Enquiry';
$webMaster = 'lukecottingham@hotmail.co.uk';

function checkEmail($email) {
if (!preg_match("/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/" , $email)) {
return false;
}
return true;
}

if (!empty($name) && !empty($email) && !empty($subject) && !empty($message))
{
if(checkEmail($email)==FALSE)
{
echo "Invalid email address!";
echo "$form";
}
else
{
$body = <<<EOD
<br><hr><br>
Name: $name<br>
Email: $email<br>
Artist: $artist<br>
Subject: $subject<br>
Message: $message<br>
EOD;

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$seccess = mail($webMaster, $emailSubject, $body, $headers);
echo "Your request has been submitted";
}

}
else {echo "You must fill out all required fields $form";}
}


if ($name || $subject || $email || $message || $artist) {}
else
{
echo "$form";
}
?>




<!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">


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


</head>

<body>
<div class="main">
<div class="blok_header">
<div class="blok_header_resize">
<div class="search">
<form id="form1" name="form1" method="post" action="">
<span>
<input name="q" class="keywords" id="textfield" maxlength="50" value="Search..." type="text">
</span>
<input name="b" src="../images/search.gif" class="button" type="image">
</form>
</div>
<div class="click"> <a href="#"><img src="../images/RSS_1.gif" alt="picture" border="0" height="23" width="24"></a>
<a href="#"><img src="../images/RSS_2.gif" alt="picture" border="0" height="23" width="24"></a>
<a href="#"><img src="../images/RSS_3.gif" alt="picture" border="0" height="23" width="24"></a>
<p>Sheffield's Modern and Stylish Professional Recording Facility...</p>
</div>
<div class="click"></div>
</div>
<div class="click"></div>
<div class="header">
<div class="logo"><a href="http://www.templateaccess.com/demos/woodenui/index.html"><img src="../images/logo.jpg" alt="logo" border="0" height="72" width="393"></a></div>
<div class="menu">
<ul>
<li><a href="../">Home</a></li>
<li><a href="../about">About</a></li>
<li><a href="../equipment/index.html">Equipment</a></li>
<li><a href="../gallery">Gallery</a></li>
<li><a href="../rates">Rates</a></li>
<li><a href="#" class="active">Contact</a></li>
</ul>
</div>
<div class="clr"></div>
</div>
<div class="header_text2">
<img src="../images/send_img.jpg" alt="picture" height="97" width="105">
<h2>Contact Us</h2>
<div class="clr"></div>
</div>
<div class="clr"></div>
</div>
<div class="clr"></div>
<div class="body_resize">
<div class="body">
<img src="../images/h2_img_3.jpg" alt="picture" height="42" width="51">
<h3>Send us an email</h3>
<p>&nbsp;</p>
<p>If you wish to enquire about our services or want to organise a booking or quote,<br />
please fill out the form below and we will get back to you as soon as possible:</p>
<p>&nbsp;</p>
<div class="clr"></div>
<div class="body_big">


<form method="post" action="index.php" id="contactform">
<ol>
<li>
<label for="name">First Name <span class="required">*</span></label>
<input id="name" name="name" class="text">
</li>
<li>
<label for="email">Your email <span class="required">*</span></label>
<input id="email" name="email" class="text" />
</li>
<li>
<label for="artist">Band/Artist Name</label>
<input id="artist" name="artist" class="text">
</li>
<li>
<label for="subject">Subject<span class="required">*</span></label>
<input id="subject" name="subject" class="text">
</li>
<li>
<label for="message">Message <span class="required">*</span></label>
<textarea id="message" name="message" class="text" rows="6" cols="50"></textarea>
</li>
<li class="buttons">
<input name="imageField" id="imageField" src="../images/send.jpg" class="send" type="image">
<div class="clr"></div>
</li>
</ol>
</form>


</div>
<div class="block2">
<h2>Contact Details</h2>
<p>Address Info:<br>
59-62 Tapton Crescent Road <br />
Sheffield<br />S10 5DB </p>
<p>Other Contacts:<br>
Email: info@basement-studios.co.uk<br>
Website: www.basement-studios.co.uk<br>
Phone: 07790 366500</p>
<a href="#"><img src="../images/rss_1.jpg" alt="picture" class="rss" border="0" height="25" width="24"></a>
<a href="#"><img src="../images/rss_2.jpg" alt="picture" class="rss" border="0" height="25" width="24"></a>
<a href="#"><img src="../images/rss_3.jpg" alt="picture" class="rss" border="0" height="25" width="24"></a>
<a href="#"><img src="../images/rss_4.jpg" alt="picture" class="rss" border="0" height="25" width="24"></a>
<a href="#"><img src="../images/rss_5.jpg" alt="picture" class="rss" border="0" height="25" width="24"></a>
<a href="#"><img src="../images/rss_6.jpg" alt="picture" class="rss" border="0" height="25" width="24"></a>
<a href="#"><img src="../images/rss_7.jpg" alt="picture" class="rss" border="0" height="25" width="24"></a>
<a href="#"><img src="../images/rss_8.jpg" alt="picture" class="rss" border="0" height="25" width="24"></a>
<a href="#"><img src="../images/rss_9.jpg" alt="picture" class="rss" border="0" height="25" width="24"></a>
</div>
<div class="clr"></div>
</div>
<div class="clr"></div>
</div>
</div>
<div class="footer">
<div class="footer_resize">
<p class="leftt">&copy; Copyright Basement Studios Sheffield. All Rights Reserved. <a href="../"><br />
Home</a> | <a href="../contact">Contact</a> | <a href="../rates">Rates</a></p>
<p class="right">Site Map | Privacy Policy</p>
<div class="clr"></div>
</div>
<div class="clr"></div>
</div>
<script></script></body></html>

bluewalrus
10-05-2010, 05:20 PM
What happens currently?

fastsol1
10-05-2010, 06:48 PM
I got this Bluewalrus, I have been helping him the whole time and he just needed to move some stuff around.
I guess I assumed that you would know how or what to do with the code I gave you but I guess not, no big deal it was a simple fix. Now because I can't see this on your server while testing I can't be 100% on this, but I think this should work, if not let me know and I'll look at it on your site with the link you gave before.

<!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">


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


</head>

<body>
<div class="main">
<div class="blok_header">
<div class="blok_header_resize">
<div class="search">
<form id="form1" name="form1" method="post" action="">
<span>
<input name="q" class="keywords" id="textfield" maxlength="50" value="Search..." type="text">
</span>
<input name="b" src="../images/search.gif" class="button" type="image">
</form>
</div>
<div class="click"> <a href="#"><img src="../images/RSS_1.gif" alt="picture" border="0" height="23" width="24"></a>
<a href="#"><img src="../images/RSS_2.gif" alt="picture" border="0" height="23" width="24"></a>
<a href="#"><img src="../images/RSS_3.gif" alt="picture" border="0" height="23" width="24"></a>
<p>Sheffield's Modern and Stylish Professional Recording Facility...</p>
</div>
<div class="click"></div>
</div>
<div class="click"></div>
<div class="header">
<div class="logo"><a href="http://www.templateaccess.com/demos/woodenui/index.html"><img src="../images/logo.jpg" alt="logo" border="0" height="72" width="393"></a></div>
<div class="menu">
<ul>
<li><a href="../">Home</a></li>
<li><a href="../about">About</a></li>
<li><a href="../equipment/index.html">Equipment</a></li>
<li><a href="../gallery">Gallery</a></li>
<li><a href="../rates">Rates</a></li>
<li><a href="#" class="active">Contact</a></li>
</ul>
</div>
<div class="clr"></div>
</div>
<div class="header_text2">
<img src="../images/send_img.jpg" alt="picture" height="97" width="105">
<h2>Contact Us</h2>
<div class="clr"></div>
</div>
<div class="clr"></div>
</div>
<div class="clr"></div>
<div class="body_resize">
<div class="body">
<img src="../images/h2_img_3.jpg" alt="picture" height="42" width="51">
<h3>Send us an email</h3>
<p>&nbsp;</p>
<p>If you wish to enquire about our services or want to organise a booking
or quote,<br />
please fill out the form below and we will get back to you as soon as
possible:</p>
<p>&nbsp;</p>
<div class="clr"></div>
<div class="body_big">

<?php
if (isset($_POST['imageField']) || isset($_POST['imageField_x']))
{
$name = $_POST['name'];
$email = trim($_POST['email']);
$artist = $_POST['artist'];
$subject = $_POST['subject'];
$message = $_POST['message'];
}

$form = "<form method=\"post\" action=\"index.php\" id=\"contactform\">
<ol>
<li>
<label for=\"name\">First Name <span class=\"required\">*</span></label>
<input id=\"name\" name=\"name\" class=\"text\" value=\"$name\"/>
</li>
<li>
<label for=\"email\">Your email <span class=\"required\">*</span></label>
<input id=\"email\" name=\"email\" class=\"text\" value=\"$email\"/>
</li>
<li>
<label for=\"artist\">Band/Artist Name</label>
<input id=\"artist\" name=\"artist\" class=\"text\" value=\"$artist\">
</li>
<li>
<label for=\"subject\">Subject<span class=\"required\">*</span></label>
<input id=\"subject\" name=\"subject\" class=\"text\" value=\"$subject\">
</li>
<li>
<label for=\"message\">Message <span class=\"required\">*</span></label>
<textarea id=\"message\" name=\"message\" class=\"text\" rows=\"6\" cols=\"50\">$message</textarea>
</li>
<li class=\"buttons\">
<input name=\"imageField\" id=\"imageField\" src=\"images/send.jpg\" class=\"send\" type=\"image\">
<div class=\"clr\"></div>
</li>
</ol>
</form>";

if (isset($_POST['imageField']) || isset($_POST['imageField_x']))
{
$emailSubject = 'Basement Studio Web Enquiry';
$webMaster = 'lukecottingham@hotmail.co.uk';

function checkEmail($email) {
if (!preg_match("/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/" , $email)) {
return false;
}
return true;
}

if (!empty($name) && !empty($email) && !empty($subject) && !empty($message))
{
if(checkEmail($email)==FALSE)
{
echo "Invalid email address!";
echo "$form";
}
else
{
$body = <<<EOD
<br><hr><br>
Name: $name<br>
Email: $email<br>
Artist: $artist<br>
Subject: $subject<br>
Message: $message<br>
EOD;

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$seccess = mail($webMaster, $emailSubject, $body, $headers);
echo "Your request has been submitted";
}

}
else {echo "You must fill out all required fields $form";}
}
if ($name || $subject || $email || $message || $artist) {}
else
{
echo "$form";
}
?>
</div>
<div class="block2">
<h2>Contact Details</h2>
<p>Address Info:<br>
59-62 Tapton Crescent Road <br />
Sheffield<br />S10 5DB </p>
<p>Other Contacts:<br>
Email: info@basement-studios.co.uk<br>
Website: www.basement-studios.co.uk<br>
Phone: 07790 366500</p>
<a href="#"><img src="../images/rss_1.jpg" alt="picture" class="rss" border="0" height="25" width="24"></a>
<a href="#"><img src="../images/rss_2.jpg" alt="picture" class="rss" border="0" height="25" width="24"></a>
<a href="#"><img src="../images/rss_3.jpg" alt="picture" class="rss" border="0" height="25" width="24"></a>
<a href="#"><img src="../images/rss_4.jpg" alt="picture" class="rss" border="0" height="25" width="24"></a>
<a href="#"><img src="../images/rss_5.jpg" alt="picture" class="rss" border="0" height="25" width="24"></a>
<a href="#"><img src="../images/rss_6.jpg" alt="picture" class="rss" border="0" height="25" width="24"></a>
<a href="#"><img src="../images/rss_7.jpg" alt="picture" class="rss" border="0" height="25" width="24"></a>
<a href="#"><img src="../images/rss_8.jpg" alt="picture" class="rss" border="0" height="25" width="24"></a>
<a href="#"><img src="../images/rss_9.jpg" alt="picture" class="rss" border="0" height="25" width="24"></a>
</div>
<div class="clr"></div>
</div>
<div class="clr"></div>
</div>
</div>
<div class="footer">
<div class="footer_resize">
<p class="leftt">© Copyright Basement Studios Sheffield. All Rights
Reserved. <a href="../"><br />
Home</a> | <a href="../contact">Contact</a> | <a href="../rates">Rates</a></p>
<p class="right">Site Map | Privacy Policy</p>
<div class="clr"></div>
</div>
<div class="clr"></div>
</div>
<script></script></body></html>
One other thing is obviously if you want the form to layout differently you need to modify that your self in the form coding towards to top of the code.

fastsol1
10-05-2010, 08:42 PM
I just realized something that was wrong in the last post, I fixed it so if you tried it already scrap it and copy the code in the last post again cause I just changed it.

lcot
10-06-2010, 04:00 PM
Ahh, I see now... see Im learning :)

The only problem is that if you try to validate and it is wrong, it displays the message at the top perfect however for some reason the form copies itself below :/ weird, i've looked up and down the code but cannot seem to find why... what do you think?
Again, thanks so much for the help, couldn't get this far without you.

fastsol1
10-07-2010, 01:27 AM
Here, just change this:

if ($name || $subject || $email || $message || $artist) {}
else
{
echo "$form";
}

to this:

if (isset($_POST['imageField']) || isset($_POST['imageField_x'])) {}
else
{
echo "$form";
}

This is what I wanted it to be but I forgot to change it back after I was testing it.