473,395 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Question Regarding Form Security

***newbie_request***

I have a simple program that inserts user details into a MySQL database -
The form validation is dealt with by another program that contains the html
form

I would like to ensure no-one can create a separate form and post to my
input program thereby bypassing my validation functions

My question is :- Is there a way I check that the $_POST vars have come from
a php file on the webserver and halt the sql input with a security warning
if they're coming from a different source?

Perhaps I'm approaching this from the wrong angle - Am I?
TIA

Dave
Jul 31 '06 #1
6 1299
Katash wrote:
***newbie_request***

I have a simple program that inserts user details into a MySQL database -
The form validation is dealt with by another program that contains the html
form

I would like to ensure no-one can create a separate form and post to my
input program thereby bypassing my validation functions

My question is :- Is there a way I check that the $_POST vars have come from
a php file on the webserver and halt the sql input with a security warning
if they're coming from a different source?

Perhaps I'm approaching this from the wrong angle - Am I?
TIA

Dave

Not reliably. But rather, you should be validating the data server-side
just before inserting it into the database.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 31 '06 #2
Katash wrote:
I have a simple program that inserts user details into a MySQL database -
The form validation is dealt with by another program that contains the html
form

I would like to ensure no-one can create a separate form and post to my
input program thereby bypassing my validation functions

My question is :- Is there a way I check that the $_POST vars have come from
a php file on the webserver and halt the sql input with a security warning
if they're coming from a different source?

Perhaps I'm approaching this from the wrong angle - Am I?
Before performing the insert, you could check $_SERVER['HTTP_REFERER']
to see if it matches where you expect the user to come from.
See: http://us3.php.net/manual/en/reserved.variables.php

The problem with that, as the PHP manual states, is that not all
clients provide this information, and if they do, it can't always be
trusted. So as you asked, you may be approaching from the wrong angle
here.

The bottom line in web security is DON'T TRUST ANYTHING. You may have
already done validation on the form, but if you're sending it somewhere
else, then check it again when it gets there.

Jul 31 '06 #3
mo*******************@yahoo.com wrote:
Katash wrote:
>I have a simple program that inserts user details into a MySQL
database - The form validation is dealt with by another program that
contains the html form

I would like to ensure no-one can create a separate form and post to
my input program thereby bypassing my validation functions

My question is :- Is there a way I check that the $_POST vars have
come from a php file on the webserver and halt the sql input with a
security warning if they're coming from a different source?

Perhaps I'm approaching this from the wrong angle - Am I?

Before performing the insert, you could check $_SERVER['HTTP_REFERER']
to see if it matches where you expect the user to come from.
Please don't do this. HTTP_REFERER is useless for affirming anything.
You can only use it in the negative, and even then you should not trust
it if you'd face adverse consequences for false negatives.

Katash - How about passing a randomly-generated token in a hidden
variable on the form and ensuring it comes back intact? Or using
sessions?

miguel
--
Photos from 40 countries on 5 continents: http://travel.u.nu
Latest photos: Malaysia; Thailand; Singapore; Spain; Morocco
Airports of the world: http://airport.u.nu
Jul 31 '06 #4
Perhaps I'm approaching this from the wrong angle - Am I?

YES, if what i'm inferring about your scripts is that the validation
and insert scripts are separate.

Your validation and insert/update MySQL scripts should be one and the
same.

That way it doesn't matter where the post or get information comes
from, your server script will always validate the data before inserting
or updating to mysql.

Also if you're asking this question because you are trying to defeat
bots or other auto form filler-ourters think about adding a
captcha/challenge response to your form.

Jul 31 '06 #5
On Mon, 31 Jul 2006 20:03:02 +0000, Katash wrote:
***newbie_request***

I have a simple program that inserts user details into a MySQL database
- The form validation is dealt with by another program that contains the
html form

I would like to ensure no-one can create a separate form and post to my
input program thereby bypassing my validation functions

My question is :- Is there a way I check that the $_POST vars have come
from a php file on the webserver and halt the sql input with a security
warning if they're coming from a different source?

Perhaps I'm approaching this from the wrong angle - Am I?
How would a form from another source have access to your database server?

--
The USA Patriot Act is the most unpatriotic act in American history.
Feingold-Obama '08 - Because the Constitution isn't history,
It's the law.

Jul 31 '06 #6

Katash wrote:
***newbie_request***

I have a simple program that inserts user details into a MySQL database -
The form validation is dealt with by another program that contains the html
form

I would like to ensure no-one can create a separate form and post to my
input program thereby bypassing my validation functions

My question is :- Is there a way I check that the $_POST vars have come from
a php file on the webserver and halt the sql input with a security warning
if they're coming from a different source?

Perhaps I'm approaching this from the wrong angle - Am I?
TIA

Dave
before you put anything into a database in which a user types or can
edit in anyway, such as any get or post variables, run them through
mysql_escape_string or mysql_real_escape_string at least.

Aug 1 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read...
1
by: cartoonsmart | last post by:
Hi I got the following script going; <?php $sendTo = "myemail@myemail.com"; $subject = "My web site reply"; $headers = "From: " . $_POST; $headers .= "<" . $_POST . ">\r\n"; $headers .=...
2
by: Dean R. Henderson | last post by:
For an ASP.NET web application, is there a way for one session (with appropriate security authorization) to set a HttpSessionState variable to point to another session and execute the Abandon...
5
by: Oriane | last post by:
Hi, With Asp.net 2.0, when a internet user logs in with a "login authentication form", is the password encrypted when it is sent to the server ? Is is hashed ? Best regards
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.