Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Lionsanime Directory   High Bandwidth Dedicated Servers   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 05-10-2008, 03:24 PM   #1 (permalink)
Junior Member
 
Join Date: 05-07-08
Posts: 4
iTrader: 0 / 0%
Latest Blog:
None

gordon is liked by many
Need help with contact form

I have added a contact form to my site and it seems to be working. What I would like to do know, is add some type of feature were an individual is limited on the number of times they can submit my form over a given time interval(lets say five minutes).

Below you will find my contact form and contact.php file.

Code:
contact form <form id="form" method="post" action="contact.php" enctype="multipart/form-data" name="form"> <strong><u>All fields marked * are required</u></strong> <br /><br style="line-height:15px;" /> <div class="col_box"> <div class="col_box_1"> <strong>Subject</strong> <div class="t_form"><input name="content" type="text" value="" /></div> <strong>Name *</strong> <div class="t_form"><input name="visitor" type="text" value="" /></div> <strong>Email *</strong> <div class="t_form"><input name="visitormail" type="text" value="" /></div> <br /><br style="line-height:3px;" /> <strong><a href="http://www.***.com/verification.html" onclick="window.open('http://www.***.com/verification.html','popup','width=400,height=500,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">whats this?</a></strong>*<img src="captcha.php"><input type="text" name="vercode" value="Place above code here" /><br> </form> </div> <div class="col_box_2"> <strong>Message *</strong> <textarea name="details" cols="2" rows="2" ></textarea> <strong style="margin:0 15px 0 40px;"> <input type="submit" name="submit" value="Submit"><input type="reset" name="Submit2" value="Reset"> </div> <div class="clear"></div> </div> </form> </div>
Code:
contact.php file <?php $content = $_POST['content']; $visitor = $_POST['visitor']; $visitormail = $_POST['visitormail']; $details = $_POST['details']; if (eregi('http:', $details)) { die ("We don't allow visitors to submit website links due to security reasons, Please click the browser back button and remove the link."); } if(empty($visitor) || empty($visitormail) || empty($details )) { echo "<h2>Use the browser back button and fill in all required form fields</h2>\n"; die (""); } if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) { echo "<h2>Use browser back button and enter a valid e-mail address</h2>\n"; $badinput = "<h2>A valid email looks like this: someone@someone.com</h2>\n"; echo $badinput; die (""); } session_start(); if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='') { echo "<h2>Use browser back button and enter the correct verification code.</h2>\n"; die (""); } $todayis = date("l, F j, Y") ; $content = $content ; $subject = $content; $details = stripcslashes($details); $message = " $todayis \n Subject: $content \n Message: $details \n From: $visitor ($visitormail)\n "; $from = "From: $visitormail\r\n"; mail("email@email.com", $subject, $message, $from); ?> <p align="center"> Date: <?php echo $todayis ?> <br /> Email was recieved - Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> ) <br /> Subject: <?php echo $subject ?> <br /> Message:<br /> <?php $notesout = str_replace("\r", "<br/>", $details); echo $notesout; ?> <br /> <br /><br /> <a href="contactus.html"> Back to contact page </a> </p>
Any help would be greatly appreciated.

If you also notice anything else that can be added or changed please let me know

Thanks

Last edited by gordon : 05-10-2008 at 03:36 PM.
gordon is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 05-10-2008, 03:45 PM   #2 (permalink)
Contributing Member
 
Join Date: 07-24-06
Posts: 625
iTrader: 1 / 100%
Latest Blog:
None

nasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nice
When submitting the form simply set cookie with a 5 minutes lifetime (if such does not exist yet). If cookie already exist display warning or whatever you want.
nasty.web is online now  
Add Post to del.icio.us
Reply With Quote
Old 05-11-2008, 03:11 PM   #3 (permalink)
Junior Member
 
Join Date: 05-07-08
Posts: 4
iTrader: 0 / 0%
Latest Blog:
None

gordon is liked by many
I did some searching and I found this:

setcookie ( string $name [, string $value [, int $expire [, string $path [, string $domain [, bool $secure [, bool $httponly ]]]]]] )

Is this what I have to put in my contact.php file.

Also could you help me figure out what code goes into my contact form.

Thanks
gordon is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-12-2008, 09:59 AM   #4 (permalink)
Contributing Member
 
ag3nt42's Avatar
 
Join Date: 04-22-08
Posts: 99
iTrader: 0 / 0%
Latest Blog:
None

ag3nt42 is liked by many
http://w3schools.com/php/php_cookies.asp
ag3nt42 is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-12-2008, 05:41 PM   #5 (permalink)
Junior Member
 
Join Date: 05-07-08
Posts: 4
iTrader: 0 / 0%
Latest Blog:
None

gordon is liked by many
I have added this code to my contact.php file:

Code:
setcookie("contact", "contactform", time()+3600); if ($_POST["contactform"]) ; { echo "<h2>You must wait one hour, before submitting more information via the contact form.</h2>\n"; die (""); }
What I would like to happen is for a cookie to be placed on the visitors computer when they first submit the form(This seems to have been accomplished). I want to do this to prevent the visitor from spamming my inbox.


What I would like to happen now is have the php file display an error message if the cookie already exists on the visitors computer. As it stands now i get the above error message "You must wait one hour, before submitting more information via the contact form". even if the cookie is non existent. So can someone please help me figure this out.

I will also like the cookie to expire after 5 minutes, but i have no idea what the time value needs to be changed to.

Thanks
Gordon
gordon is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-13-2008, 04:58 AM   #6 (permalink)
Contributing Member
 
ag3nt42's Avatar
 
Join Date: 04-22-08
Posts: 99
iTrader: 0 / 0%
Latest Blog:
None

ag3nt42 is liked by many
3600 secs... is 1 hour so 300 secs is 5 min

found a decent little time converter here

http://www.convertunit.com/time_converter.php
ag3nt42 is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-13-2008, 11:29 AM   #7 (permalink)
Possible Terrorist
 
kwvarga's Avatar
 
Join Date: 10-13-03
Location: Tuscaloosa, AL or Atlanta
Posts: 4,904
iTrader: 0 / 0%
Latest Blog:
A+ Certification

kwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web pro
Send a message via AIM to kwvarga
change your code to this, you have a ; that is ending the if statement.. surprised that even compiles

Code:
setcookie("contact", "contactform", time()+3600); if ($_POST["contactform"]) { echo "<h2>You must wait one hour, before submitting more information via the contact form.</h2>\n"; die (""); }
__________________
Kyle Varga
"m3lt/theSpear"
student, web designer/coder, future IT consultant
Experience: PHP/MySQL, Java, C++, MS-SQL
kwvarga is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-13-2008, 11:56 AM   #8 (permalink)
Contributing Member
 
Join Date: 07-24-06
Posts: 625
iTrader: 1 / 100%
Latest Blog:
None

nasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nice
if ($_COOKIE["contactform"]) {
echo "<h2>You must wait one hour, before submitting more information via the contact form.</h2>\n";
die ("");
}

setcookie("contact", "contactform", time()+3600);

P.S. if you set cookie and then immediately check if it exists - it will obviously exist Moved setcookie after if statement.
nasty.web is online now  
Add Post to del.icio.us
Reply With Quote
Old 05-13-2008, 12:04 PM   #9 (permalink)
Possible Terrorist
 
kwvarga's Avatar
 
Join Date: 10-13-03
Location: Tuscaloosa, AL or Atlanta
Posts: 4,904
iTrader: 0 / 0%
Latest Blog:
A+ Certification

kwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web pro
Send a message via AIM to kwvarga
Good call nasty.web, can't believe I didn't catch that.
__________________
Kyle Varga
"m3lt/theSpear"
student, web designer/coder, future IT consultant
Experience: PHP/MySQL, Java, C++, MS-SQL
kwvarga is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-13-2008, 04:44 PM   #10 (permalink)
Junior Member
 
Join Date: 05-07-08
Posts: 4
iTrader: 0 / 0%
Latest Blog:
None

gordon is liked by many
Thanks for the help My website is now complete.
gordon is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need a contact form for my web site iorgyzu88 Coding Forum 10 03-17-2007 05:56 PM
Wordpress Contact Form casperl Blogging Forum 1 02-25-2007 04:00 PM
Contact form issues RonHollingsworth Coding Forum 1 02-08-2007 08:54 AM
Contact Form and Go To Url Question popstalin Coding Forum 2 02-07-2007 10:36 AM
Help me with a better contact form andreeam Coding Forum 4 11-18-2006 01:56 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 02:08 PM.
© Copyright 2008 V7 Inc