PHP Problem

Caporegime
Joined
28 Jan 2003
Posts
39,881
Location
England
So I am having a real problem getting PHP to work.

I have the below code:

<?php
if(isset($_POST['submit_form'])){
if(isset($_POST['name']) && isset($_POST['email']) && isset($_POST['comments'])){
// Code to execute if everything is fine
}else{
$error="incomplete";
}
}
?>

<!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=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php if(isset($error)){echo "<p>Please complete all of the required fields</p>";} ?>

<form method="post" action="contact.php">
Name*:<br /><input type="text" name="name" style="<?php if(isset($_POST['submit_form']) && !isset($_POST['name'])){echo "background:#b12828;";} ?>" /><br />
Email Address*:<br /><input type="text" name="email" style="<?php if(isset($_POST['submit_form']) && !isset($_POST['email'])){echo "background:#b12828;";} ?>" /><br />
Phone Number:<br /><input type="text" name="phone" style="<?php if(isset($_POST['submit_form']) && !isset($_POST['phone'])){echo "background:#b12828;";} ?>" /><br />
Comments*:<br /><textarea name="comments" style="<?php if(isset($_POST['submit_form']) && !isset($_POST['comments'])){echo "background:#b12828;";} ?>"></textarea><br />
<input type="submit" value="Submit" />
<input type="hidden" name="submit_form" value="y" />
</form>
</body>
</html>

Which I am just using a test here (http://digital-blacksmith.co.uk/set/contact.php) but the bloody thing will just not work, it doesn't give me anything.

Have I done some something obviously wrong with my code? I cannot see it and it's driving me insane.
 
Caporegime
OP
Joined
28 Jan 2003
Posts
39,881
Location
England
It's not my code was just a sample validation form I was trying out but it just wouldn't work. I just couldn't see what was wrong with it at all.
 
Caporegime
OP
Joined
28 Jan 2003
Posts
39,881
Location
England
I appreciate the advice. Truth be known it's the first piece of php I have tried to use so I was trying it out to try and work back how it worked. Then it didn't work and I was thrown.
 
Back
Top Bottom