homepage Welcome to WebmasterWorld Guest from 23.20.34.25
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Trying to add a text box for form for phone number
stevenb 1959




msg:4117162
 11:51 pm on Apr 16, 2010 (gmt 0)

I want to add a text field to my form that would be to post a visitors phone number. I dont know much about PHP and I bought the script pre_built as is to email the form information to my email.
Here is the code:

<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script>
<style>
.textfieldServerError {
display:block;
margin:0px;
color:#CC3333;
border: 1px solid #CC3333;
}
</style>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css" />
<!-- InstanceEndEditable -->
<style type="text/css" media="screen">
<!--
@import url("../css/stevesstyles.css");
.style2 {color: #FF0000}
-->
</style>

<script src="../Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>

<body>





<br />
<form action="" method="post" name="emailContact" id="emailContact" onsubmit="">
<div style="width:inherit">

<label for="Contact_Name" >Your name:</label>
<br />
<span id="sprytextfield1">
<input name="Contact_Name" type="text" class="inputValue" id="Contact_Name" onblur="if (document.getElementById('nameServerError')) document.getElementById('nameServerError').style.display='none'" value="" />
<span class="textfieldRequiredMsg">A value is required.</span></span>
<input name="addblock" type="text" id="addblock" style="display:none" value="" />
<br />
<label for="Email_address" >Email Address:</label>

<br />
<span id="sprytextfield2">
<input name="Email_address" type="text" class="inputValue" id="Email_address" onblur="if (document.getElementById('emailServerError')) document.getElementById('emailServerError').style.display='none'" value="" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
<input name="seconddblock" id="seconddblock" type="text" style="display:none" value="" />
<br />
<label for="Comments" >Comments:</label>

<br />
<span id="sprytextarea1">
<textarea name="Comments" class="inputText" id="Comments" onblur="if (document.getElementById('commentsServerError')) document.getElementById('commentsServerError').style.display='none'" ></textarea>
<span class="textareaRequiredMsg">A value is required.</span></span>

<br />
<label for="Security_code" >
Which day comes before sunday? </label>

<br />
<span id="sprytextfield4">
<input name="Security_question" type="text" class="inputValue" id="Security_question" onblur="if (document.getElementById('securityServerError')) document.getElementById('securityServerError').style.display='none'" maxlength="40" />
<span class="textfieldRequiredMsg">A value is required.</span></span>
<p>
<br />
<input type="submit" value="Submit" class="inputButton"/>
</p>

<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp; </p>
</div>
</form>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none", {validateOn:["blur"]});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "email", {validateOn:["blur"]});
var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1", {validateOn:["blur"]});
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "none", {validateOn:["blur"]});
//-->
</script>

Any help would be appreciated
Thanks
Steve

 

stevenb 1959




msg:4117169
 12:33 am on Apr 17, 2010 (gmt 0)

Here is my code which is wrong with a text field for phone number added:

$WAFV_Errors = "";
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact_Name"]))?$_POST["Contact_Name"]:"") . "",true,1);
$WAFV_Errors .= WAValidateEM(((isset($_POST["Email_address"]))?$_POST["Email_address"]:"") . "",true,2);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Comments"]))?$_POST["Comments"]:"") . "",true,3);
$WAFV_Errors .= WAValidateEM(((isset($_POST["Phone_number"]))?$_POST["Phone_number"]:"") . "",true,9);
$WAFV_Errors .= WAValidateLE(((isset($_POST["Security_question"]))?strtolower($_POST["Security_question"]):"") . "",((isset($_SESSION["random_answer"]))?strtolower($_SESSION["random_answer"]):"") . "",true,5);
$WAFV_Errors .= WAValidateRX(((isset($_POST["addblock"]))?$_POST["addblock"]:"") . "","/^$/i",false,6);
$WAFV_Errors .= WAValidateRX(((isset($_POST["seconddblock"]))?$_POST["seconddblock"]:"") . "","/^$/i",false,7);
$WAFV_Errors .= WAValidateRX(((isset($_POST["thirddblock"]))?$_POST["thirddblock"]:"") . "","/^$/i",false,8);
if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"contact");





<form action="" method="post" name="emailContact" id="emailContact" onsubmit="">
<div style="width:inherit">
<label for="Contact_Name" >Your name:</label>
<br />
<span id="sprytextfield1">
<input name="Contact_Name" type="text" class="inputValue" id="Contact_Name" onblur="if (document.getElementById('nameServerError')) document.getElementById('nameServerError').style.display='none'" value="<?php echo(ValidatedField("contact","Contact_Name")) ?>" />
<span class="textfieldRequiredMsg">A value is required.</span></span>
<input name="addblock" type="text" id="addblock" style="display:none" value="" />
<?php
if (ValidatedField("contact","contact")) {
if ((strpos((",".ValidatedField("contact","contact").","), "," . "1" . ",") !== false || "1" == "")) {
if (!(false)) {
?>
<span id="nameServerError" class="textfieldServerError">Please provide your name.</span>
<?php //WAFV_Conditional contact.php contact(1:)
}
}
}?>
<br />
<label for="Email_address" >Email Address:</label>
<br />
<span id="sprytextfield2">
<input name="Email_address" type="text" class="inputValue" id="Email_address" onblur="if (document.getElementById('emailServerError')) document.getElementById('emailServerError').style.display='none'" value="<?php echo(ValidatedField("contact","Email_address")) ?>" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
<input name="seconddblock" id="seconddblock" type="text" style="display:none" value="" />
<?php
if (ValidatedField("contact","contact")) {
if ((strpos((",".ValidatedField("contact","contact").","), "," . "2" . ",") !== false || "2" == "")) {
if (!(false)) {
?>
<span id="emailServerError" class="textfieldServerError">Please provide your email address so we can get back in touch with you.</span>
<?php //WAFV_Conditional contact.php contact(2:)
}
}
}?>
<br />
<label for="Phone_number" >Phone Number:</label>
<br />
<span id="sprytextfield3">
<input name="Phone_number" type="text" class="inputValue" id="Phone_number" onblur="if (document.getElementById('emailServerError')) document.getElementById('emailServerError').style.display='none'" value="<?php echo(ValidatedField("contact","Phone_number")) ?>" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
<input name="thirddblock" id="thirddblock" type="text" style="display:none" value="" />
<?php
if (ValidatedField("contact","contact")) {
if ((strpos((",".ValidatedField("contact","contact").","), "," . "9" . ",") !== false || "9" == "")) {
if (!(false)) {
?>
<span id="emailServerError" class="textfieldServerError">Please provide your phone number with area code so we can get back in touch with you.</span>
<?php //WAFV_Conditional contact.php contact(4:)
}
}
}?>
<br />
<label for="Comments" >Comments:</label>
<br />
<span id="sprytextarea1">
<textarea name="Comments" class="inputText" id="Comments" onblur="if (document.getElementById('commentsServerError')) document.getElementById('commentsServerError').style.display='none'" ><?php echo(ValidatedField("contact","Comments")) ?></textarea>
<span class="textareaRequiredMsg">A value is required.</span></span>
<?php
if (ValidatedField("contact","contact")) {
if ((strpos((",".ValidatedField("contact","contact").","), "," . "3" . ",") !== false || "3" == "")) {
if (!(false)) {
?>
<span id="commentsServerError" class="textfieldServerError">Please let us know how we can assist you.<br />
</span>
<?php //WAFV_Conditional contact.php contact(3:)
}
}
}?>

<br />
<label for="Security_code" >
<?php require_once("WA_ValidationToolkit/WAVT_CaptchaSecurityQuestion.php"); ?>
</label>
<br />
<span id="sprytextfield4">
<input name="Security_question" type="text" class="inputValue" id="Security_question" onblur="if (document.getElementById('securityServerError')) document.getElementById('securityServerError').style.display='none'" maxlength="40" />
<span class="textfieldRequiredMsg">A value is required.</span></span>
<p>
<?php
if (ValidatedField("contact","contact")) {
if ((strpos((",".ValidatedField("contact","contact").","), "," . "5" . ",") !== false || "5" == "")) {
if (!(false)) {
?>
<span id="securityServerError" class="textfieldServerError">Your answer was not correct.</span>
<?php //WAFV_Conditional contact.php contact(4:)
}
}
}?>
<br />
<input type="submit" value="Submit" class="inputButton"/>
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp; </p>
</div>
</form>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none", {validateOn:["blur"]});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "email", {validateOn:["blur"]});var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "ephone", {validateOn:["blur"]});
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "none", {validateOn:["blur"]});
var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1", {validateOn:["blur"]});

g1smd




msg:4117170
 12:34 am on Apr 17, 2010 (gmt 0)

If this stuff is going into a database, do consider breaking the phone number up into country code, area code, and local number parts as separate items.

You'll find it a lot easier to make mass data changes when a whole area is assigned a new area code, or the country code changes for a whole country - as has happened many times before.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved