Frosty
08-20-2006, 11:29 PM
On my website I have this very simple php form script shown here:
http://www.jpwear.com/retailinquiry.html
However do you see the form used on this other website... type some text into their form... do you see how your text shows up as RED instead of BLACK when you are typing info into their form?
http://www.rxpinoy.com/doctor_ask.php?submit=askthis&docid=CA002GAS
I really like that and would like my form to be the same way... meaning when somebody is typing into my form the text shows up as red instead of plain black... I've pasted the simple php script I'm using on my site below... does anybody know what I need to exactly add to my script to make that happen?
<?
$youremail="juliet@jpwear.com";
$yoursubject="Request To Become A Retailer";
$thankspage="http://www.jpwear.com";
mail("$youremail", "$yoursubject", "
Company Name: $x_Company_Name
<br>
Years In Business: $x_Business_Years
<br>
Address: $x_Address
<br>
City: $x_City
<br>
State: $x_State
<br>
Zip: $x_Zip
<br>
Contact Person: $x_Contact
<br>
Position: $x_Position
<br>
Phone: $x_Phone
<br>
Fax: $x_Fax
<br>
Email: $x_Email
<br>
How Did You Hear About Us: $x_Find_Us
<br>
Type Of Store You Have: $x_Store_Type
<br>
Type Of Brands You Carry: $x_Brand_Type
<br>
Price Point: $x_Price_Point
<br>
Customer Age Range: $x_Customer_Age_Range
<br>
Trade Shows: $x_Trade_Shows
<br>
APPAI Number: $x_APPAI
<br>
ASI Number: $x_ASI
<br>
Comments: $x_Comments
","From: $youremail\nReply-To:$youremail\nContent-Type: text/html; charset=iso-8859-1: PHP/");
header('Location:'.$thankspage);
?>
sea otter
08-20-2006, 11:56 PM
Actually, you don't need to do anything in PHP. It's all in the html and css.
1. Put this in your css file:
.form-input
{
font-family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #990000;
margin: 0px;
padding: 0px;
}
That's the exact code from the site you mentioned.
2. In your .html file where you have the form, add the following to each "input" form element:
class="form-input"
Taking one of your form elements as an example, here's the original:
<INPUT TYPE=TEXT NAME="x_Company_Name" VALUE="" SIZE=25 MAXLENGTH=40>
and here's what you should now have:
<INPUT TYPE=TEXT class="form-input" NAME="x_Company_Name" VALUE="" SIZE=25 MAXLENGTH=40>
Just do that for every input element you want in red.
horizon
08-21-2006, 09:38 AM
Additionally to what it states above, it would be best, for security issues, to
change this block:
$thankspage="http://www.jpwear.com";
mail("$youremail", "$yoursubject", "
Company Name: $x_Company_Name
<br>
Years In Business: $x_Business_Years
<br>
Address: $x_Address
<br>
City: $x_City
<br>
State: $x_State
<br>
Zip: $x_Zip
<br>
Contact Person: $x_Contact
<br>
Position: $x_Position
<br>
Phone: $x_Phone
<br>
Fax: $x_Fax
<br>
Email: $x_Email
<br>
How Did You Hear About Us: $x_Find_Us
<br>
Type Of Store You Have: $x_Store_Type
<br>
Type Of Brands You Carry: $x_Brand_Type
<br>
Price Point: $x_Price_Point
<br>
Customer Age Range: $x_Customer_Age_Range
<br>
Trade Shows: $x_Trade_Shows
<br>
APPAI Number: $x_APPAI
<br>
ASI Number: $x_ASI
<br>
Comments: $x_Comments
","From: $youremail\nReply-To:$youremail\nContent-Type: text/html; charset=iso-8859-1: PHP/");
header('Location:'.$thankspage);
replace with:
$thankspage="http://www.jpwear.com";
$x_Company_Name = (isset($_POST['x_Company_Name'])) ? (stripslashes(trim($_POST['x_Company_Name']))) : "";
$x_Company_Years = (isset($_POST['x_Company_Years'])) ? trim($_POST['x_Company_Years']) : "";
$x_Address = (isset($_POST['x_Address'])) ? (stripslashes(trim($_POST['x_Address']))) : "";
$x_City = (isset($_POST['x_City'])) ? (stripslashes(trim($_POST['x_City']))) : "";
$x_State = (isset($_POST['x_State'])) ? (stripslashes(trim($_POST['x_State']))) : "";
$x_Zip = (isset($_POST['x_Zip'])) ? intval(trim($_POST['x_Zip'])) : 0;
$x_Contact = (isset($_POST['x_Contact'])) ? (stripslashes(trim($_POST['x_Contact']))) : "";
$x_Position = (isset($_POST['x_Position'])) ? (stripslashes(trim($_POST['x_Position']))) : "";
$x_Phone = (isset($_POST['x_Phone'])) ? intval(trim($_POST['x_Phone'])) : 0;
$x_Fax = (isset($_POST['x_Fax'])) ? intval(trim($_POST['x_Fax'])) : 0;
$x_Email = (isset($_POST['x_Email'])) ? (stripslashes(trim($_POST['x_Email']))) : "";
$x_Find_Us = (isset($_POST['x_Find_Us'])) ? (stripslashes(trim($_POST['x_Find_Us']))) : "";
$x_Store_Type = (isset($_POST['x_Store_Type'])) ? (stripslashes(trim($_POST['x_Store_Type']))) : "";
$x_Brand_Type = (isset($_POST['x_Brand_Type'])) ? (stripslashes(trim($_POST['x_Brand_Type']))) : "";
$x_Price_Point = (isset($_POST['x_Price_Point'])) ? intval(trim($_POST['x_Price_Point'])) : 0;
$x_Customer_Age_Range = (isset($_POST['x_Customer_Age_Range'])) ? trim($_POST['x_Customer_Age_Range']) : "";
$x_Trade_Shows = (isset($_POST['x_Trade_Shows'])) ? (stripslashes(trim($_POST['x_Trade_Shows']))) : "";
$x_APPAI = (isset($_POST['x_APPAI'])) ? (stripslashes(trim($_POST['x_APPAI']))) : "";
$x_ASI = (isset($_POST['x_ASI'])) ? (stripslashes(trim($_POST['x_ASI']))) : "";
$x_Comments = (isset($_POST['x_Comments'])) ? (strip_tags(trim($_POST['x_Comments']))) : "";
if (empty($x_Company_Name) || empty($x_Business_Years) || empty($x_Address) || empty($x_City) || empty($x_State) || empty($x_Zip) || empty($x_Contact) || empty($x_Position) || empty($x_Phone) || empty($x_Fax) || empty($x_Email) || empty($x_Find_Us) || empty($x_Store_Type) || empty($x_Brand_Type) || empty($x_Price_Point) || empty($x_Customer_Age_Range) || empty($x_Trade_Shows) || empty($x_APPAI) || empty($x_ASI) || empty($x_Comments)) {
die ('One of the fields has a missing entry.');
} else {
mail("$youremail", "$yoursubject", "
Company Name: $x_Company_Name
<br>
Years In Business: $x_Business_Years
<br>
Address: $x_Address
<br>
City: $x_City
<br>
State: $x_State
<br>
Zip: $x_Zip
<br>
Contact Person: $x_Contact
<br>
Position: $x_Position
<br>
Phone: $x_Phone
<br>
Fax: $x_Fax
<br>
Email: $x_Email
<br>
How Did You Hear About Us: $x_Find_Us
<br>
Type Of Store You Have: $x_Store_Type
<br>
Type Of Brands You Carry: $x_Brand_Type
<br>
Price Point: $x_Price_Point
<br>
Customer Age Range: $x_Customer_Age_Range
<br>
Trade Shows: $x_Trade_Shows
<br>
APPAI Number: $x_APPAI
<br>
ASI Number: $x_ASI
<br>
Comments: $x_Comments
","From: $youremail\nReply-To:$youremail\nContent-Type: text/html; charset=iso-8859-1: PHP/");
header('Location:'.$thankspage);
}
;)
sea otter
08-21-2006, 09:51 AM
Ahhhhhh, good point; I'm gettin' soft! Didn't really look at the code from a security perspective. But now that you mention it, one more thing:
Wrap the striplashes in a call to htmlentities(). That way you can display "untrusted" data (data entered by the user) on your page.
horizon
08-21-2006, 09:57 AM
htmlentities()
You could also replace that function with htmlspecialchars(). ;)
sea otter
08-21-2006, 10:01 AM
htmlentities is a little more comprehensive, so I always use it over htmlspecial chars. As per the php docs:
This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities.