Forum Moderators: coopster
<!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>Easy Offer Form</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
<script language="JavaScript">
function checkForm()
{
var cname, cemail, chomephone, cworkphone, cotherphone, ctimetocall, carea, cpropertytype,
cbedrooms, cagent, cagreement, crepairs, cpricerange, ccurrentpayments, cwhen, ccredit, cownrent,
ccomment;
with(window.document.msgform)
{
cname = sname;
cemail = email;
chomephone = homephone;
cworkphone = workphone;
cotherphone = otherphone;
ctimetocall = timetocall;
carea = area;
cpropertytype = propertytype;
cbedrooms = bedrooms;
cagent = agent;
cagreement = agreement;
crepairs = repairs;
cpricerange = pricerange;
ccurrentpayments = currentpayments;
cwhen = when;
ccredit = credit;
cownrent = ownrent;
ccomment = comment;
}
if(trim(cname.value) == '')
{
alert('Please enter your name');
cname.focus();
return false;
}
else if(trim(cemail.value) == '')
{
alert('Please enter your email');
cemail.focus();
return false;
}
else if(!isEmail(trim(cemail.value)))
{
alert('Email address is not valid');
cemail.focus();
return false;
}
else if(trim(chomephone.value) == '')
{
alert('Please enter your home phone number');
csubject.focus();
return false;
}
else if((trim(cworkphone.value) == '') and (trim(cotherphone.value) == ''))
{
alert('Please enter an alternate phone number');
cmessage.focus();
return false;
}
else if(trim(ctimetocall.value) == '')
{
alert('Please enter the best time to call you');
csubject.focus();
return false;
}
else if(trim(carea.value) == '')
{
alert('Please enter the area you are looking to move to');
csubject.focus();
return false;
}
else if(trim(cbedrooms.value) == '')
{
alert('Please enter the minimum number of bedrooms that would be acceptable to
you');
csubject.focus();
return false;
}
else if(trim(cpricerange.value) == '')
{
alert('Please enter the pricerange of the home you are seeking');
csubject.focus();
return false;
}
else if(trim(ccurrentpayments.value) == '')
{
alert('Please enter the amount you are currently paying for rent or mortgage');
csubject.focus();
return false;
}
else
{
cname.value = trim(cname.value);
cemail.value = trim(cemail.value);
chomephone.value = trim(chomephone.value);
cworkphone.value = trim(cworkphone.value);
cotherphone.value = trim(cotherphone.value);
ctimetocall.value = trim(ctimetocall.value);
carea.value = trim(carea.value);
cbedrooms.value = trim(cbedrooms.value);
cpricerange.value = trim(cpricerange.value);
ccurrentpayments.value = trim(ccurrentpayments.value);
return true;
}
}
/*
Strip whitespace from the beginning and end of a string
Input : a string
*/
function trim(str)
{
return str.replace(/^\s+¦\s+$/g,'');
}
/*
Check if a string is in valid email format.
Returns true if valid, false otherwise.
*/
function isEmail(str)
{
var regex =
/^[-_.a-z0-9]+@(([-_a-z0-9]+\.)+(ad¦ae¦aero¦af¦ag¦ai¦al¦am¦an¦ao¦aq¦ar¦arpa¦as¦at¦au¦aw¦az¦ba¦bb¦bd¦
be¦bf¦bg¦bh¦bi¦biz¦bj¦bm¦bn¦bo¦br¦bs¦bt¦bv¦bw¦by¦bz¦ca¦cc¦cd¦cf¦cg¦ch¦ci¦ck¦cl¦cm¦cn¦co¦com¦coop¦cr¦
cs¦cu¦cv¦cx¦cy¦cz¦de¦dj¦dk¦dm¦do¦dz¦ec¦edu¦ee¦eg¦eh¦er¦es¦et¦eu¦fi¦fj¦fk¦fm¦fo¦fr¦ga¦gb¦gd¦ge¦gf¦gh¦
gi¦gl¦gm¦gn¦gov¦gp¦gq¦gr¦gs¦gt¦gu¦gw¦gy¦hk¦hm¦hn¦hr¦ht¦hu¦id¦ie¦il¦in¦info¦int¦io¦iq¦ir¦is¦it¦jm¦jo¦
jp¦ke¦kg¦kh¦ki¦km¦kn¦kp¦kr¦kw¦ky¦kz¦la¦lb¦lc¦li¦lk¦lr¦ls¦lt¦lu¦lv¦ly¦ma¦mc¦md¦mg¦mh¦mil¦mk¦ml¦mm¦mn¦
mo¦mp¦mq¦mr¦ms¦mt¦mu¦museum¦mv¦mw¦mx¦my¦mz¦na¦name¦nc¦ne¦net¦nf¦ng¦ni¦nl¦no¦np¦nr¦nt¦nu¦nz¦om¦org¦pa
¦pe¦pf¦pg¦ph¦pk¦pl¦pm¦pn¦pr¦pro¦ps¦pt¦pw¦py¦qa¦re¦ro¦ru¦rw¦sa¦sb¦sc¦sd¦se¦sg¦sh¦si¦sj¦sk¦sl¦sm¦sn¦so
¦sr¦st¦su¦sv¦sy¦sz¦tc¦td¦tf¦tg¦th¦tj¦tk¦tm¦tn¦to¦tp¦tr¦tt¦tv¦tw¦tz¦ua¦ug¦uk¦um¦us¦uy¦uz¦va¦vc¦ve¦vg¦
vi¦vn¦vu¦wf¦ws¦ye¦yt¦yu¦za¦zm¦zw)¦(([0-9][0-9]?¦[0-1][0-9][0-9]¦[2][0-4][0-9]¦[2][5][0-5])\.){3}([0-
9][0-9]?¦[0-1][0-9][0-9]¦[2][0-4][0-9]¦[2][5][0-5]))$/i;
return regex.test(str);
}
<div id="nav-main">
<ul title="Major Site Sections">
<li><a href="index.htm">Home</a></li>
</ul>
</div>
<div id="bannershadow">
</div>
<div id="content" style="width: 646px; height: 985px">
<p style="text-align: center"> </p>
<p><font
size="5"><b> &nbs
p;
</b></font><u><font size="5"><b>Buyer's List Information</b></font></u></p>
<p><font size="3">If you are interested in being contacted when we have a
property in the area that you are looking for a home, please fill out the form
below. When we have something that meets your needs, we will contact you
and let you know.</font></p>
<?php
$errmsg = ''; // error message
$sname = ''; // sender's name
$email = ''; // sender's email addres
$homephone = ''; // buyer's home phone number
$workphone = ''; // buyer's work phone number
$otherphone = ''; // buyer's alternate phone number
$timetocall = ''; // best time to call
$area = ''; // the area to which the buyer hopes to move
$propertytype = ''; //The type of property the buyer would prefer
$bedrooms = ''; // Minimum number of bedrooms required
$agent = ''; // Are they working with an agent?
$agreement = ''; // is there an agreement with the agent?
$repairs = ''; // willing to make repairs?
$pricerange = ''; // What price range are they looking for?
$currentpayments = ''; // the amount the buyer currently pays per month for rent or mortgage
$when = ''; // how soon the buyer wants to buy
$credit = ''; // the buyer's credit
$ownrent = ''; // do they own or rent?
$comment = ''; // Any additional comments or notes
if(isset($_POST['submit']))
{
$sname = $_POST["Name"];
$email = $_POST["Email"];
$homephone = $_POST["Home_Phone"];
$workphone = $_POST["Work_Phone"];
$otherphone = $_POST["Other_Phone"];
$timetocall = $_POST["Best_Time_to_Call"];
$area = $_POST["Area_Looking_to_Move_to"];
$propertytype = $_POST["Type_of_Property"];
$bedrooms = $_POST["Bedrooms"];
$agent = $_POST["Working_with_Agent"];
$agreement = $_POST["If_yes_when_listing_expires"];
$repairs = $_POST["Any_repairs_needed"];
$pricerange = $_POST["Price_Range_Sought"];
$currentpayments = $_POST["Current_Monthly_Payments"];
$when = $_POST["how_fast"];
$credit = $_POST["credit"];
$ownrent = $_POST["Currently_rent"];
$comment = $_POST["Notes_and_comments"];
if(trim($sname) == '')
{
$errmsg = 'Please enter your name';
}
else if(trim($email) == '')
{
$errmsg = 'Please enter your email address';
}
else if(!isEmail($email))
{
$errmsg = 'Your email address is not valid';
}
else if(trim($homephone) == '')
{
$errmsg = 'Please enter your home phone number';
}
else if((trim($workphone) == '') AND ((trim($otherphone) == '')
{
$errmsg = 'Please enter an alternate phone number';
}
else if(trim($timetocall) == '')
{
$errmsg = 'Please enter the best time to call you';
}
else if(trim($area) == '')
{
$errmsg = 'Please let us know where you would like to move to';
}
else if(trim($bedrooms) == '')
{
$errmsg = 'Please enter the minimum amount of bedrooms you would like';
}
else if(trim($repairs) == '')
{
$errmsg = 'Please let us know if you are willing to make repairs';
}
else if(trim($pricerange) == '')
{
$errmsg = 'Please let us know the pricerange you are working in';
}
else if(trim($currentpayments) == '')
{
$errmsg = 'Please enter the amount you are currently paying for rent or mortgage';
}
if($errmsg == '')
{
if(get_magic_quotes_gpc()!= 1)
{
$sname = addslashes($sname);
$email = addslashes($email);
$homephone = addslashes($homephone);
$workphone = addslashes($workphone);
$otherphone = addslashes($otherphone);
$timetocall = addslashes($timetocall);
$area = addslashes($area);
$agreement = addslashes($agreement);
$repairs = addslashes($repairs);
$pricerange = addslashes($pricerange);
$currentpayments = addslashes($currentpayments);
$comments = addslashes($comments);
}
?>
<?php
if(!isset($_POST['submit']) ¦¦ $errmsg!= '')
?><?php
if ($submit) {
// process form
include config.php
include opendb.php
$sql = "INSERT INTO buyerslist
(cname,cemail,chomephone,cworkphone,cotherphone,ctimetocall,carea,cpropertytype,cbedrooms,cagent,cag
reement,crepairs,cpricerange,ccurrentpayments,cwhen,ccredit,cownrent,ccomments) VALUES
('$sname','$email','$homephone','$workphone','$otherphone','$timetocall','$area','$propertytype','$b
edrooms','$agent','$agreement','$repairs','$pricerange','$currentpayments','$when','$credit','$ownre
nt','$comments')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
} else{
// display form
?>
<div align="center" class="errmsg"><?=$errmsg;?></div>
<form method="post" action="<?php echo $PHP_SELF?>">
<table width="630" height="823">
<tr>
<th align="right" width="329">
<font size="2">Name:
</font>
</th>
<td width="291" height="23">
<input type="text" name="Name" size="53" />
</td>
</tr>
<tr>
<th align="right" width="329">
<font size="2">Home Phone:
</font>
</th>
<td width="291" height="23">
<input type="text" name="Home_Phone" size="53" />
</td>
</tr>
<tr>
<th align="right" width="329">
<font size="2">Work Phone:
</font>
</th>
<td width="291" height="23">
<input type="text" name="Work_Phone" size="53" />
</td>
</tr>
<tr>
<th align="right" width="329">
<font size="2">Other Phone:
</font>
</th>
<td width="291" height="23">
<input type="text" name="Other_Phone" size="53" />
</td>
</tr>
<tr>
<th align="right" width="329">
<font size="2">Best Time to Call:
</font>
</th>
<td width="291" height="23">
<input type="text" name="Best_Time_to_Call" size="53" />
</td>
</tr>
<tr>
<th align="right" width="329">
<font size="2">Email:
</font>
</th>
<td width="291" height="23">
<input type="text" name="Email" size="53" />
</td>
</tr>
<tr>
<th align="right" width="329">
<font size="2">Area Looking to Move to:
</font>
</th>
<td width="291" height="25">
<input type="text" name="Area_Looking_to_Move_to" size="53" />
</td>
</tr>
<tr>
<th align="right" width="329">
<font size="2">Type of Property Seeking:
</font>
</th>
<td width="291" height="23">
<select name="Type_of_Property" size="1">
<option value="Single Family Detached">Single Family Detached</option>
<option value="Condo">Condo</option>
<option value="Duplex - single unit">Duplex - single unit</option>
<option value="Duplex - both units">Duplex - both units</option>
<option value="Townhome">Townhome</option>
<option value="Mobile home">Mobile home</option>
<option value="Multi-family 2-4 units">Multi-family 2-4 units</option>
<option value="Multi-family 5 or more">Multi-family 5 or more</option>
</select>
</td>
</tr>
<tr>
<th align="right" width="329">
<font size="2">Number of
Bedrooms Sought:
</font>
</th>
<td width="291" height="23">
<input type="text" name="Bedrooms" size="30" />
</td>
</tr>
<tr>
<th align="right" width="329">
<font size="2">Working with a Real Estate Agent?:
</font>
</th>
<td width="291" height="23">
<select name="Working_with_Agent" size="1">
<option value="No">No</option>
<option value="Yes">Yes</option>
</select>
</td>
</tr>
<tr>
<th align="right" width="329">
<font size="2">If yes, did you sign an agreement with the Agent?:
</font>
</th>
<td width="291" height="25">
<input type="text" name="If_yes_when_listing_expires" size="30" />
</td>
</tr>
<tr>
<th align="right" width="329">
<font size="2">Interested in Paying Less by Making Repairs Yourself?:
</font>
</th>
<td width="291" height="25">
<input type="text" name="Any_repairs_needed" size="54" />
</td>
</tr>
<tr>
<th align="right" width="329">
<font size="2">Price Range Sought:
</font>
</th>
<td width="291" height="23">
<input type="text" name="Price_Range_Sought" size="30" />
</td>
</tr>
<tr>
<th align="right" width="329">
<font size="2"> Current
Monthly Rent or Mortgage:
</font>
</th>
<td width="291" height="23">
<input type="text" name="Current_Monthly_Payments" size="30" />
</td>
</tr>
<tr>
<th align="right" width="329">
<font size="2">When are you looking to buy?:
</font>
</th>
<td width="291" height="25">
<select name="how_fast" size="1">
<option value="Today">Today</option>
<option value="30 days">30 days</option>
<option value="3 months">3 months</option>
<option value="No rush">No rush</option>
</select>
</td>
</tr>
<tr>
<th align="right" width="329">
<font size="2">Your credit is:</font></th>
<td width="291" height="25">
<select name="credit" size="1">
<option value="Good">Good</option>
<option value="OK">OK</option>
<option value="Bad">Bad</option>
</select>
</td>
</tr>
<tr>
<th align="right" width="329">
<font size="2">Do you currently own or rent?:
</font>
</th>
<td width="291" height="25">
<select name="Currently_rent" size="1">
<option value="Rent">Rent</option>
<option value="Own">Own</option>
</select>
</td>
</tr>
<tr>
<th align="right" width="329">
<font size="2">Notes and comments:
</font>
</th>
<td width="291" height="249">
<textarea name="Notes_and_comments" cols="30" rows="10">Tell us anything here that you feel we
should know.</textarea>
</td>
</tr>
<tr>
<th width="329" align="right"><br /></th>
<td width="291" height="34">
<input type="submit" name="submit" value="Submit Form" />
</td>
</tr>
</table><input type="hidden" name="_vDeckformid" value="178" />
</form>
<?php
}
function isEmail($email)
{
return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]¦[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad¦ae¦a
ero¦af¦ag¦ai¦al¦am¦an¦ao¦aq¦ar¦arpa¦as¦at¦au¦aw¦az¦ba¦bb¦bd¦be¦bf¦bg¦bh¦bi¦biz¦bj¦bm¦bn¦bo¦br¦bs¦bt¦
bv¦bw¦by¦bz¦ca¦cc¦cd¦cf¦cg¦ch¦ci¦ck¦cl¦cm¦cn¦co¦com¦coop¦cr¦cs¦cu¦cv¦cx¦cy¦cz¦de¦dj¦dk¦dm¦do¦dz¦ec¦e
du¦ee¦eg¦eh¦er¦es¦et¦eu¦fi¦fj¦fk¦fm¦fo¦fr¦ga¦gb¦gd¦ge¦gf¦gh¦gi¦gl¦gm¦gn¦gov¦gp¦gq¦gr¦gs¦gt¦gu¦gw¦gy¦
hk¦hm¦hn¦hr¦ht¦hu¦id¦ie¦il¦in¦info¦int¦io¦iq¦ir¦is¦it¦jm¦jo¦jp¦ke¦kg¦kh¦ki¦km¦kn¦kp¦kr¦kw¦ky¦kz¦la¦l
b¦lc¦li¦lk¦lr¦ls¦lt¦lu¦lv¦ly¦ma¦mc¦md¦mg¦mh¦mil¦mk¦ml¦mm¦mn¦mo¦mp¦mq¦mr¦ms¦mt¦mu¦museum¦mv¦mw¦mx¦my¦
mz¦na¦name¦nc¦ne¦net¦nf¦ng¦ni¦nl¦no¦np¦nr¦nt¦nu¦nz¦om¦org¦pa¦pe¦pf¦pg¦ph¦pk¦pl¦pm¦pn¦pr¦pro¦ps¦pt¦pw
¦py¦qa¦re¦ro¦ru¦rw¦sa¦sb¦sc¦sd¦se¦sg¦sh¦si¦sj¦sk¦sl¦sm¦sn¦so¦sr¦st¦su¦sv¦sy¦sz¦tc¦td¦tf¦tg¦th¦tj¦tk¦
tm¦tn¦to¦tp¦tr¦tt¦tv¦tw¦tz¦ua¦ug¦uk¦um¦us¦uy¦uz¦va¦vc¦ve¦vg¦vi¦vn¦vu¦wf¦ws¦ye¦yt¦yu¦za¦zm¦zw)$¦(([0-
9][0-9]?¦[0-1][0-9][0-9]¦[2][0-4][0-9]¦[2][5][0-5])\.){3}([0-9][0-9]?¦[0-1][0-9][0-9]¦[2][0-4][0-9]¦
[2][5][0-5]))$/i"
,$email));
}
?>
</div>
<p> </p>
</body>
</html>
and welcome to Webmasterworld
Nowhere in your script you have defined:
if ($submit) {
// process form
As this value is never set, then it's false, so form is never processed to mysql.
Moreover try not to post irrelevant code (eg whole beginning is irrelevant, as well as javascript, as well as addslashes and checking if values are correct.
If you try to clean your code for this forum, you may find it much easier to find mistakes as well.
So solution, I think would be to write:
if ($_POST['submit']) {// process form
Regards
Michal
PS. Webmasterworld has a strange behavior with pipes, but don't worry