Contact Us 2.0. - php Form

Author Topic: Contact Us 2.0.  (Read 18888 times)

Offline admin

  • Administrator
  • *****
  • Posts: 67
  • Karma: +10/-0
  • Gender: Male
    • View Profile
Contact Us 2.0.
« on: March 23, 2010, 04:43:51 PM »


Contact Us 2.0.

Download: Members
« Last Edit: March 23, 2010, 04:49:00 PM by admin »

Offline ScOrPiOnE

  • Supporter
  • **
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Contact Us 2.0.
« Reply #1 on: April 21, 2010, 07:44:14 AM »
Sorry bro, i faced abig proplem and i can't solve it cuz i'm new on javascript
look this page appear when i press Submit

i hope i find an solution with you
i need another thing , i need small banner for your gr8 site to add on my site adv. cuz i learned alot of things from this site in small time. Thanks

Offline coin

  • Supporter
  • **
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Contact Us 2.0.
« Reply #2 on: April 22, 2010, 03:48:23 AM »
mail() Function.Mail Failed to connect to mailserver at "localhost"

That means you don't have mail server installed or working on your local machine.
 :(

Offline ScOrPiOnE

  • Supporter
  • **
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Contact Us 2.0.
« Reply #3 on: April 24, 2010, 10:46:07 AM »
can you tell me how to set up mail server on my local host machine cuz i'm not apro. on php scripts and i want to complete my site fast. Thanks for reply

Offline boyfrom75

  • VIP
  • ****
  • Posts: 21
  • Karma: +5/-0
    • View Profile
Re: Contact Us 2.0.
« Reply #4 on: September 10, 2010, 02:49:12 PM »
Someone knows how to add a phone number option to this form ??

Please contact me at:  latinomax  at   gmail  dot  com

Offline niko

  • VIP
  • ****
  • Posts: 15
  • Karma: +1/-1
    • View Profile
Re: Contact Us 2.0.
« Reply #5 on: September 11, 2010, 12:49:56 AM »
contact.php header
Code: [Select]

<?php $email 'email@example.com'?>
<head>
<SCRIPT LANGUAGE="JavaScript">
function checkEmail(ccForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(ccForm.jemail.value)){
return (true)
}
alert("Invalid E-mail Address! Please re-enter.")
return (false)
}
//  End -->
</script>
<script type="text/javascript">
function make_blank()
{
document.ccform.jname.value ="";
}
</script>
<script type="text/javascript">
function makes_blank()
{
document.ccform.jemail.value ="";
}
</script>
<script type="text/javascript">
function smakes_blank()
{
document.ccform.jphone.value ="";
}
</script>
<script type="text/javascript">
function make_blanks()
{
document.ccform.jfeed.value ="";
}
</script>
<style type="text/css">
h4{
 font-family:"trebuchet ms";
color:#555;
}
#formes {
align:center;
margin:auto 0;
width:469px;
padding-top:10px;
padding-bottom:10px;
border:1px dotted #ccc;
background-color:#FAFAFA;
font-family:"trebuchet ms";
font-size:12px;
}

#fname {
              width:355px;
border:#ccc solid 1px;
background:#fff url(images/user.png) no-repeat left;
              padding-left:44px;
              font-family:"trebuchet ms";
              font-size:13px;
              color:#555;
}
#femail {
              width:355px;
border:#ccc solid 1px;
background:#fff url(images/email.png) no-repeat left;
              padding-left:44px;
              font-family:"trebuchet ms";
              font-size:13px;
              color:#555;
}
#fphone {
              width:355px;
border:#ccc solid 1px;
background:#fff url(images/SOMEPHONE IMAGE) no-repeat left;
              padding-left:44px;
              font-family:"trebuchet ms";
              font-size:13px;
              color:#555;
}
#sfeed {
              width:355px;
border:#ccc solid 1px;
background:#fff url(images/text_signature.png) no-repeat top left;
              padding-left:44px;
              font-family:"trebuchet ms";
              font-size:13px;
              color:#555;
             
}
#sbutton {
             width:82px;
             height:25px;
             border:0;
             display:block;
              background-image: url(images/button.png);
              background-repeat: no-repeat;
              font-family:"trebuchet ms";
              font-size:13px;
              color:#555;
             
}


</style>
</head>

Offline niko

  • VIP
  • ****
  • Posts: 15
  • Karma: +1/-1
    • View Profile
Re: Contact Us 2.0.
« Reply #6 on: September 11, 2010, 12:51:26 AM »
contact.php body
Code: [Select]
<body>
<div align="center">
<?php
if(isset($_POST['submit']))
{
$jname $_POST['jname'];
$jemail $_POST['jemail'];
$jphone $_POST['jphone'];
$jfeed $_POST['jfeed'];
////////
$time date ("h:i A"); 
$date date ("l, F jS, Y");
$urlh getenv(HTTP_HOST);
$url "http://$urlh";
$ip $_SERVER['REMOTE_ADDR'];
$headers 'From: System Admin';
$subject "Info";
$body $_POST['body'];
$bodys "Message:\n$jfeed\n\n
Contact Us Form\n\n$date at $time.\n\n
IP Address.$ip \n\n
E Address: $jemail\n\n
Name: $jname \n\n
Url: $url\n\n 
Phone: $jphone \n\n"

///////////////
$name=array($jname,$jemail,$jphone,$jfeed);
foreach (
$name as $name
{
if (
ereg("^\.",$name)) {
echo 
"<center><div id=\"formes\">Invalid Characters:<a href=\"javascript:history.go(-1)\">Go Back</a></div></center>";  
 Die();
}
if (
ereg("\<"$name)) {
echo 
"<center><div id=\"formes\">Invalid Characters:<a href=\"javascript:history.go(-1)\">Go Back</a></div></center>";  
 Die();
}
if (
ereg("\["$name)) {
echo 
"<center><div id=\"formes\">Invalid Characters:<a href=\"javascript:history.go(-1)\">Go Back</a></div></center>";  
 Die();
}
if (
ereg("\`"$name)) {
echo 
"<center><div id=\"formes\">Invalid Characters:<a href=\"javascript:history.go(-1)\">Go Back</a></div></center>";  
 Die();
}
if (
strlen($name) > 250) {
echo 
"<center><div id=\"formes\">The field cannot contain more than 150 characters:
<a href=\"javascript:history.go(-1)\">Go Back</a></div></center>"
;  
 Die();
}
if (
strlen($name) < 4) {
echo 
"<center><div id=\"formes\">Min 4 characters:
<a href=\"javascript:history.go(-1)\">Go Back</a></div></center>"
;  
 Die();
}
}
$body $body $bodys;
mail($email$subject$body"From: $email");
echo 
"<center><div id=\"formes\">Thank You</div></center>";  
}else{
?>

<h4>Contact Us</h4>
<form name=ccform id="formes" action="<?php echo $PHP_SELF?>" method="post" onSubmit="return checkEmail(this)">
<p><input name="jname" type="text" id="fname" value='Enter Your Name' onclick="make_blank();"></p>
<p><input name="jemail" type="text" id="femail" value='Enter Your Email' onclick="makes_blank();"></p>
<p><input name="jphone" type="text" id="fphone" value='Enter Your Phone' onclick="smakes_blank();"></p>
<p><textarea name="jfeed" id="sfeed" value='Your Message' onclick="make_blanks();" rows="3" cols="25">Your Message</textarea></p>
<p><input id="sbutton" type="submit" name="submit" value="Submit"></p>
</form>
<?php
}
?>

</div>

Offline boyfrom75

  • VIP
  • ****
  • Posts: 21
  • Karma: +5/-0
    • View Profile
Re: Contact Us 2.0.
« Reply #7 on: September 12, 2010, 07:42:01 PM »
NIKO...... !!!!!!!!!!!!!

You are the best...!!!!  If you are a girl I give you lot of kisses and hugs...!!!!

Man ... you are the man... !!!!

Thank You........!!!!.........Thank You........!!!!.........Thank You........!!!!.........Thank You........!!!!.........Thank You........!!!!.........Thank You........!!!!.........

I put the phone image and works perfect.....!!!

The only thing I wish I can have is:  To have the form in a  contact.html  page. because my contact page in my website is html file and this form is write into a contact.php file.

I dont want to have a popup window .. I want to have the form in my contact.html  page..

But is ok . Im sure there is a way to do that.. Im sure it will take me months to find out ....  Lol

NIKO... thanks again to help me with this...  You dont understand how thankful I am... I own you big time... I love this script.... Companies are charging for those scripts and they dont even look nice... This is a beautiful script and is free... :)

Offline boyfrom75

  • VIP
  • ****
  • Posts: 21
  • Karma: +5/-0
    • View Profile
Re: Contact Us 2.0.
« Reply #8 on: September 13, 2010, 11:47:54 AM »

The only thing I wish I can have is:  To have the form in a  contact.html  page. because my contact page in my website is html file and this form is write into a contact.php file.

I dont want to have a popup window .. I want to have the form in my contact.html  page..

But is ok . Im sure there is a way to do that.. Im sure it will take me months to find out ....  Lol



It is OK, If I can not put this in  a HTML  page I can use a Frame on my page...

<IFRAME style="border:1px solid #cccccc;" SRC="http://mywebsite.com/...........php" WIDTH=230 HEIGHT=440></iframe>

This will work for me...
Im wandering if I chage the extension from.php to .ttml  will work...  ?? ??? ::)

Offline boyfrom75

  • VIP
  • ****
  • Posts: 21
  • Karma: +5/-0
    • View Profile
Re: Contact Us 2.0.
« Reply #9 on: September 13, 2010, 11:52:07 AM »
Quote
Im wandering if I change the extension from.php to .ttml  will work...  ?? ??? ::)

Sorry:   change  extension   .PHP    to    .HTML

Offline leony

  • VIP
  • ****
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Re: Contact Us 2.0.
« Reply #10 on: September 13, 2010, 01:16:54 PM »
Just change extension to .php (contact.php instead contact.html) :) :)

Offline boyfrom75

  • VIP
  • ****
  • Posts: 21
  • Karma: +5/-0
    • View Profile
Re: Contact Us 2.0.
« Reply #11 on: September 17, 2010, 01:13:01 PM »
Code part  #2 because my  message exceeds the maximum allowed length (4000 characters).
Quote
#sbutton {
             width:82px;
             height:25px;
             border:0;
             display:block;
              background-image: url(images/button.png);
              background-repeat: no-repeat;
              font-family:"trebuchet ms";
              font-size:13px;
              color:#555;
             
}


</style>
</head>
<body>
<div align="center">
<?php
if(isset($_POST['submit']))
{
$jname = $_POST['jname'];
$jemail = $_POST['jemail'];
$jphone = $_POST['jphone'];
$jcity = $_POST['jcity'];
$jfeed = $_POST['jfeed'];
////////
$time = date ("h:i A");
$date = date ("l, F jS, Y");
$urlh = getenv(HTTP_HOST);
$url = "http://$urlh";
$ip = $_SERVER['REMOTE_ADDR'];
$headers = 'From: System Admin';
$subject = "You have a new contact from your website ! ";
$body = $_POST['body'];
$bodys = "Message:\n$jfeed\n\n
Contact Us Form\n\n$date at $time.\n\n
IP Address.$ip \n\n
E Address: $jemail\n\n
Name: $jname \n\n
Url: $url\n\n
Phone: $jphone \n\n";
City: $jcity \n\n";
///////////////
$name=array($jname,$jemail,$jphone,$jcity,$jfeed);
foreach ($name as $name)
{
if (ereg("^\.",$name)) {
echo "<center><div id=\"formes\">Invalid Characters:<a href=\"javascript:history.go(-1)\">Go Back</a></div></center>"; 
 Die();
}
if (ereg("\<", $name)) {
echo "<center><div id=\"formes\">Invalid Characters:<a href=\"javascript:history.go(-1)\">Go Back</a></div></center>"; 
 Die();
}
if (ereg("\[", $name)) {
echo "<center><div id=\"formes\">Invalid Characters:<a href=\"javascript:history.go(-1)\">Go Back</a></div></center>"; 
 Die();
}
if (ereg("\`", $name)) {
echo "<center><div id=\"formes\">Invalid Characters:<a href=\"javascript:history.go(-1)\">Go Back</a></div></center>"; 
 Die();
}
if (strlen($name) > 250) {
echo "<center><div id=\"formes\">The field cannot contain more than 150 characters:
<a href=\"javascript:history.go(-1)\">Go Back</a></div></center>"; 
 Die();
}
if (strlen($name) < 4) {
echo "<center><div id=\"formes\">Min 4 characters:
<a href=\"javascript:history.go(-1)\">Go Back</a></div></center>"; 
 Die();
}
}
$body = $body . $bodys;
mail($email, $subject, $body, "From: $email");
echo "<center><div id=\"formes\">Thank You</div></center>"; 
}else{
?>
<h4>Contact Us</h4>
<form name=ccform id="formes" action="<?php echo $PHP_SELF; ?>" method="post" onSubmit="return checkEmail(this)">
<p><input name="jname" type="text" id="fname" value='Enter Your Name' onclick="make_blank();"></p>
<p><input name="jemail" type="text" id="femail" value='Enter Your Email' onclick="makes_blank();"></p>
<p><input name="jphone" type="text" id="fphone" value='Enter Your Phone' onclick="smakes_blank();"></p>
<p><input name="jcity" type="text" id="fcity" value='Enter City and State' onclick="smakes_blank();"></p>
<p><textarea name="jfeed" id="sfeed" value='Your Message' onclick="make_blanks();" rows="3" cols="25">Your Message</textarea></p>
<p><input id="sbutton" type="submit" name="submit" value="Submit"></p>
</form>
<?php
}
?>
</div>

Offline boyfrom75

  • VIP
  • ****
  • Posts: 21
  • Karma: +5/-0
    • View Profile
Re: Contact Us 2.0.
« Reply #12 on: September 17, 2010, 01:15:51 PM »
Hello, Im having a small problem.

Im trying to add City and State, to this form and Im getting this error:

Parse error: syntax error, unexpected ':' in  /my-website/contact.php on line 148

NIKO already added a " phone " option to this script and works perfect !!
 But I tried to add a option for " City and state" Im getting this error..
Someone knows what is wrong in the script ?

NIKO = thanks again for your big help. If you accept a paypal donation for your help.. I will be happy to do it...  :)

================================

 Code part  #1 because my  message exceeds the maximum allowed length (4000 characters).

Quote
<?php $email = 'my-email@gmail.com'; ?>
<head>
<SCRIPT LANGUAGE="JavaScript">
function checkEmail(ccForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(ccForm.jemail.value)){
return (true)
}
alert("Invalid E-mail Address! Please re-enter.")
return (false)
}
//  End -->
</script>
<script type="text/javascript">
function make_blank()
{
document.ccform.jname.value ="";
}
</script>
<script type="text/javascript">
function makes_blank()
{
document.ccform.jemail.value ="";
}
</script>
<script type="text/javascript">
function smakes_blank()
{
document.ccform.jphone.value ="";
}
</script>
<script type="text/javascript">
function smakes_blank()
{
document.ccform.jcity.value ="";
}
</script>
<script type="text/javascript">
function make_blanks()
{
document.ccform.jfeed.value ="";
}
</script>
<style type="text/css">
h4{
 font-family:"trebuchet ms";
color:#555;
}
#formes {
align:center;
margin:auto 0;
width:469px;
padding-top:10px;
padding-bottom:10px;
border:1px dotted #ccc;
background-color:#FAFAFA;
font-family:"trebuchet ms";
font-size:12px;
}

#fname {
              width:355px;
   border:#ccc solid 1px;
   background:#fff url(images/user.png) no-repeat left;
              padding-left:44px;
              font-family:"trebuchet ms";
              font-size:13px;
              color:#555;
}
#femail {
              width:355px;
   border:#ccc solid 1px;
   background:#fff url(images/email.png) no-repeat left;
              padding-left:44px;
              font-family:"trebuchet ms";
              font-size:13px;
              color:#555;
}
#fphone {
              width:355px;
   border:#ccc solid 1px;
   background:#fff url(images/phone.png) no-repeat left;
              padding-left:44px;
              font-family:"trebuchet ms";
              font-size:13px;
              color:#555;
}
#fcity {
              width:355px;
   border:#ccc solid 1px;
   background:#fff url(images/city.png) no-repeat left;
              padding-left:44px;
              font-family:"trebuchet ms";
              font-size:13px;
              color:#555;
}
#sfeed {
              width:355px;
   border:#ccc solid 1px;
   background:#fff url(images/text_signature.png) no-repeat top left;
              padding-left:44px;
              font-family:"trebuchet ms";
              font-size:13px;
              color:#555;
             
}

Offline leony

  • VIP
  • ****
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Re: Contact Us 2.0.
« Reply #13 on: September 17, 2010, 08:35:22 PM »
Code: [Select]
Phone: $jphone \n\n";
replace with

Code: [Select]
Phone: $jphone \n\n :)

Offline boyfrom75

  • VIP
  • ****
  • Posts: 21
  • Karma: +5/-0
    • View Profile
Re: Contact Us 2.0.
« Reply #14 on: September 19, 2010, 03:31:16 PM »
 Thanks leony for your big help !  I have the code working with: email, City and State added to the original form...!!

It works perfect !!!