rendered paste body<?php
$db = mysql_connect('localhost', 'nynewh_paul','mendel');
mysql_select_db("nynewh_homes", $db);
if($_POST['submit'])
{
$v_sub=$HTTP_POST_VARS['Fsub'];
$v_contact=$HTTP_POST_VARS['Fcontact'];
$v_phone=$HTTP_POST_VARS['Fphone'];
$v_web=$HTTP_POST_VARS['Fweb'];
$v_email=$HTTP_POST_VARS['Femail'];
$v_city=$HTTP_POST_VARS['Fcity'];
$v_service=$HTTP_POST_VARS['Fservice'];
$v_comment=$HTTP_POST_VARS['Fcomment'];
$query = "INSERT INTO subs (sub,contact,phone,web,email,city,service,comment)
VALUES ('$v_sub', '$v_contact', '$v_phone', '$v_web', '$v_email', '$v_city', '$v_service', '$v_comment')";
mysql_query($query, $db);
if(mysql_error())
{
echo mysql_error(). "\n";
echo $query;
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="JavaScript">
function validate()
{
dorm=document.addsub;
if (dorm.Fsub.value == '')
{
alert("Company name cannot be empty");
return false;
}
if (dorm.Fcontact.value == '')
{
alert("Contact name cannot be empty");
return false;
}
if (dorm.Fphone.value == '')
{
alert("Phone Number cannot be empty");
return false;
}
if (dorm.Femail.value == '')
{
alert("Email cant be empty");
return false;
}
if (dorm.Fcity.value == '')
{
alert("City cannot be empty");
return false;
}
if (dorm.Fservice.value == 'XX')
{
alert("Please Select a valid Service");
return false;
}
return true;
}
</script>
</head>
<table border="0" cellspacing="0" cellpadding="5" class="grey_1" style="padding-bottom:10">
<tr>
<td>
<form method="post" id="addsub" name="addsub">
Company Name:<br />
<input type="text" name="Fsub" value="" /><br />
Contact Name:<br />
<input type="text" name="Fcontact" value="" /><br />
Contact Phone:<br />
<input type="text" name="Fphone" value="" /><br />
Email:<br />
<input type="text" name="Femail" value="" /><br />
</td>
<td>
City:<br />
<input type="text" name="Fcity" value="" /><br />
Website:(optional)<br />
<input type="text" name="Fweb" value="" /><br />
Service:<br />
<select name="Fservice">
<option value="XX" selected="selected">Select One</option>
<option value="blacktop">Blacktop
<option value="surveyor">Surveyor
<option value="electrician">Electrician
<option value="excavation">Excavation
<option value="flooring">Flooring/Carpeting
<option value="foundation">Foundation
<option value="framer">Framer
<option value="hvac">HVAC
<option value="insulation">Insulation
<option value="landscaping">Landscaping
<option value="mason">Mason
<option value="painter">Painter
<option value="plumber">Plumber
<option value="roofing">Roofing
<option value="sheetrock">Sheetrock/Taping
<option value="siding">Siding
<option value="tile">Tile
<option value="trim">Trim/Carpentry
<option value="well">Well
<option value="vendor">Vendor
<option value="other">Other
</SELECT><br />
</td>
</tr>
<tr>
<td colspan="2">
Please give additional information on the service you provide:<br />
<textarea name="fcomment" cols="50" rows="5"></textarea><br /><br />
<input type="submit" name="submit" onsubmit="return validate()"; action="ss.php" value="Add" align="right" />
</form>
</td></tr></table>
</body>
</html>