Current location: Hot Scripts Forums » General Community » Script Requests » looking for a php script to clean up form info before sending


looking for a php script to clean up form info before sending

Reply
  #1 (permalink)  
Old 04-01-08, 05:53 PM
dreamydesigner dreamydesigner is offline
Newbie Coder
 
Join Date: Apr 2008
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
looking for a php script to clean up form info before sending

I have a html page with a basic quote form, in which the form info gets emailed to me. I have recently experienced virus issues because of scripts being submitted through my form. I need some sort of php script which removes special characters or something like that, and I can add to my current for. I'm not sure what, if any, of my script you might need to see in order to answer this question. Please let me know!


Thanks so much.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 04-01-08, 06:39 PM
TheKiser TheKiser is offline
Wannabe Coder
 
Join Date: Aug 2007
Location: Texas
Posts: 151
Thanks: 0
Thanked 0 Times in 0 Posts
Give us the form and the code that emails it.
__________________
6 Steps to Successfully Solving Problems:
Step 1: RTFM ............................. Step 4: Post in ProgrammingTalk
Step 2: See Step 1. ................... Step 5: Wait for answers.
Step 3: See Step 2. ................... Step 6: While Waiting RTFM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 04-02-08, 02:39 AM
curbview.com's Avatar
curbview.com curbview.com is offline
Junior Code Guru
 
Join Date: May 2006
Posts: 555
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by TheKiser View Post
Give us the form and the code that emails it.
What for? All the OP needs is a regex to allow for certain characters being submitted. For example, the php script should not allow anything but [a-zA-Z a space and a period] to sanitize the name field. Another slightly modded regex to allow the "@" sign and, viola, you're done.

-OR-

Add a captcha to the form. Which ever is simpler for the OP.
__________________
Whatever you decide, you should make sure best security methods are used and practiced. Should you really need more help, PM me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 04-02-08, 11:30 AM
dreamydesigner dreamydesigner is offline
Newbie Coder
 
Join Date: Apr 2008
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Hi curbview,
Thanks for your suggestion. While I am not at all scared of tweaking code, I have to admit that I do not regularly write it. I am still quite a beginner, actually, more of a designer. I did not understand some of what you said, like what an "OP" is or a modded regex. Do you know of an existent script I could modify? Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 04-02-08, 11:54 AM
curbview.com's Avatar
curbview.com curbview.com is offline
Junior Code Guru
 
Join Date: May 2006
Posts: 555
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by dreamydesigner View Post
Hi curbview,
Hi,
Quote:
Originally Posted by dreamydesigner View Post
... I did not understand some of what you said, like what an "OP" is
OP stands for "Original Poster" or Original Person

Quote:
Originally Posted by dreamydesigner View Post
or a modded regex.
Here's a modded regex sample to filter out unwanted scripts in the user-submitted form you have on your web site:

PHP Code:

$name $POST_['NAME'];
// let's remove all non-alphanumeric characters from the person's name!
$name preg_replace('/[^a-zA-Z0-9 ]/'''$name); 

Quote:
Originally Posted by dreamydesigner View Post
Do you know of an existent script I could modify? Thanks.
Taking the above example and using it to filter out people or bots from submitting unwanted code through the form on your web site is easy. You could use the same regex above to filter the address field like so:
PHP Code:

$address $POST_['ADDRESS'];
// let's remove all non-alphanumeric characters from the person's address!
$address preg_replace('/[^a-zA-Z0-9 ]/'''$address); 
If you need more help, let me know.
__________________
Whatever you decide, you should make sure best security methods are used and practiced. Should you really need more help, PM me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 04-02-08, 03:11 PM
TheKiser TheKiser is offline
Wannabe Coder
 
Join Date: Aug 2007
Location: Texas
Posts: 151
Thanks: 0
Thanked 0 Times in 0 Posts
That is a fine solution if you want to strip-out all of the punctuation. Along with anything else that is not a letter, a number, or a space.

The reason I asked to see the form and the script is because he was obviously an novice and it isn't easy to fill in a form and create a virus with it. (Members here excepted.) I wanted to see how the information was collected and how it was processed since what he is describing is a major security breach that should be looked into. I guess I just wanted to give him more than a band-aid.
__________________
6 Steps to Successfully Solving Problems:
Step 1: RTFM ............................. Step 4: Post in ProgrammingTalk
Step 2: See Step 1. ................... Step 5: Wait for answers.
Step 3: See Step 2. ................... Step 6: While Waiting RTFM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 04-02-08, 04:30 PM
curbview.com's Avatar
curbview.com curbview.com is offline
Junior Code Guru
 
Join Date: May 2006
Posts: 555
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by TheKiser View Post
I guess I just wanted to give him more than a band-aid.
What do you consider to be a *band-aid* fix? Having been in programming for 15+ years, I don't know of any better way to secure an application than sanitizing user input with a solid regex.

Teach us an even better solution that is shorter code and more secure? I guess I am open to learning the "latest" fashion but rather stick to tried and true methods.... I am a Penetration Tester and this has always worked.
__________________
Whatever you decide, you should make sure best security methods are used and practiced. Should you really need more help, PM me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 04-03-08, 11:30 AM
dreamydesigner dreamydesigner is offline
Newbie Coder
 
Join Date: Apr 2008
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Script

Thanks for both of your suggestions, and for explaining them so well. It is very helpful for me. Here is my script in case either of you would care to look more. I will try adding in the code you gave me and see how it goes, curbview.

I hope it works ok to upload the script in a Word doc. I thought that pasting the whole code from the page right into the forum window might be a little much. Please let me know if it is more optimal to view another way.
Attached Files
File Type: doc quoteform_script.doc (53.5 KB, 218 views)

Last edited by dreamydesigner; 04-03-08 at 11:37 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 04-03-08, 10:58 PM
curbview.com's Avatar
curbview.com curbview.com is offline
Junior Code Guru
 
Join Date: May 2006
Posts: 555
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by dreamydesigner View Post
Please let me know if it is more optimal to view another way.
NO problem sharing code with you it is what the forum is all about "Programming Talk"... About posting code that you have a problem with:

Only post the relevant sections of your code for the world to see. ( May I also suggest in the future to not use MS WORD to upload code. Use a basic text editor )

Upload a .txt version and I will have a look.
__________________
Whatever you decide, you should make sure best security methods are used and practiced. Should you really need more help, PM me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 04-11-08, 02:31 PM
dreamydesigner dreamydesigner is offline
Newbie Coder
 
Join Date: Apr 2008
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Sorry for delay. I got tied up with some other projects and am just now able to get back to this. Below is the relevant code for my form. Thanks for taking a look.

HTML Code:
<p align="left"><img src="images/quote_header.jpg" width="765" height="234" /></p>
    <!-- InstanceEndEditable --><!-- InstanceBeginEditable name="area2" -->
    <form name="frm" action="/cgi-bin/FormMail.quoteform.pl" method="post" enctype="application/x-www-form-urlencoded" onsubmit="return validate(frm)">

Last edited by Nico; 04-11-08 at 07:01 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Send info from a form to a php page magicadmin JavaScript 3 11-07-06 03:50 PM
Looking for php mail form w/ attachments and required fields Sithlord999 Script Requests 0 08-11-06 05:14 AM
Newbie needs help using form mailer script Charmaine99 PHP 3 03-11-06 08:35 PM
Video PHP Script - New Videos Daily yelbom General Advertisements 0 03-03-06 02:04 AM
Request: text form and image uploading script (PHP) YHIEddie Script Requests 0 03-18-05 06:22 PM


All times are GMT -5. The time now is 11:01 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.