Jul 26, 2008

$_post Help - little help

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

$_post Help - little help

galexcd
Hi, how do i check if the variable is comming from the same server as the page? Example, lets say i have a log in...

the page it submits to says somthing like this:

$user=$_POST['user'];
$pass=$_POST['pass'];

how do i make sure that sombody didnt make their own form on their computer, or somthing, to submit the info to my site? I only want submitions from MY site... not sombody else...

Thanks!!

Reply

Tyssen
You could use one of PHP's reserved variables - http://au.php.net/reserved.variables - to make sure the script has been submitted from your site.

Reply

galexcd
Not to be annoying or anything, but im a little new to PHP could you give me an example

thanks!

Reply

Saint_Michael
well you can make your own forms in php that will be directed from your site to your email. what I suggest is go to pixel2life.com to read up on some of those tutorials and try them out. also search php form scripts as well which should help oyu even more.

But im not aware of people making their own form scripts and then emailing it to you that would be a waste of time and could lead into spamming as well.

Reply

WindAndWater
What I think Tyssen means is that in your form you should include a hidden field that has the server address (or some other identifying characteristic) and compare it to your actual server address.
CODE
<form action = "wherever.php" method = "post">
      [All of your form fields]
      <input type="hidden" name = "sendingIP" value = "<?php echo "$_SERVER['SERVER_ADDR']" ?>
</form>


And then in your second php page you can check
CODE
if($_POST['sendingIP'] != $_SERVER['SERVER_ADDR']")
    echo "This form was submitted from the wrong server."
else
    //do stuff


However, something like the server IP address can also be faked. I'd suggest using sessions instead. A fair session tutorial's at http://codewalkers.com/tutorials/32/1.html

 

 

 


Reply

BuffaloHELP
I have been playing around the similar call with GFXTrap.com and I am using $something = $_REQUEST["variable"] as my required input before submitting.

As I understand it, $_POST[ ] accepts no matter what when submit button is pressed. Using $_REQUEST allows to place Boolean condition before submitting.

Reply

Hamtaro
I'm not sure how easy this can be faked, but one thing you can do is to use $_SERVER['HTTP_REFERER'] and use a string comparison function (like strstr()).
An example could be:
CODE
if(!strstr('YOUR_WEBSITE_URL') {
echo "Error: Incorrect Server!";
}
else {
//Your form stuff here
}

You would need to replace YOUR_WEBSITE_URL with your site's URL, obviously. I'm not sure if browser HTTP Refers can be disabled in the browser (I think they can), but that may be one of the best options. That's about the only way I would know how to do it.

Reply

galexcd
Thanks so much all of you!!! smile.gif

especially windandwater!

All your help has been greatly appriciated! laugh.gif

Reply

Spectre
There isn't really a way you can be 100% certain the form data wasn't faked. Referer, cookie and POST data can very easily be sent in a manipulated form. For example, I could forge headers along these lines and send it to your server, and it would be none the wiser:

CODE
POST /script.php HTTP/1.1
Accept: */*
Connection: close
Host: your-host.com
Referer: http://your-host.com/page.html
Cookie: fake-cookie=fake-cookie-data;
xxx-type: application/x-www-form-urlencoded
Content-Length: 3

abc


(Note that xxx = Content - IPB is filtering it out).

A session ID can also be easily captured prior to submitting the data (it will most likely be sent either via a cookie, or attached to links), and then be posted along with it. Simply put, and just to re-iterate, there is no 100% certain way you can be sure form data is coming from a page on your server.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics
Looking for post

Searching Video's for post
advertisement



$_post Help - little help



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE