Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-17-2003, 01:27 AM   PM User | #1
Goober
New Coder

 
Join Date: Aug 2003
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Goober is an unknown quantity at this point
Question PHP Forms Question

how can i make a PHP file that will only accept "POST" commands in a form, from certian file(s)?
Goober is offline   Reply With Quote
Old 12-17-2003, 02:04 AM   PM User | #2
DrWeb
New Coder

 
Join Date: Nov 2003
Location: S.F.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
DrWeb is an unknown quantity at this point
PHP Code:
<?php

$request 
$_SERVER['REQUEST_URI'];
$method $_SERVER['REQUEST_METHOD'];

if (
$request == '/myform.php' && $method == 'POST'){
    ....
}
?>
__________________
there are no stupid questions, but there are stupid answers
DrWeb is offline   Reply With Quote
Old 12-17-2003, 03:05 AM   PM User | #3
Goober
New Coder

 
Join Date: Aug 2003
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Goober is an unknown quantity at this point
thanks, but i have a couple more questions . in the if statement, are the two "&" symbols needed, or do you only need one? and why are there 2 "=" signs after $request and $method variables in the if statement?
Goober is offline   Reply With Quote
Old 12-17-2003, 03:49 AM   PM User | #4
Spookster
Supreme Overlord


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 6,222
Thanks: 4
Thanked 80 Times in 79 Posts
Spookster will become famous soon enough
It sounds like you have never programmed before nor used PHP. You might want to learn some of the basics of PHP and programming in general before you try to dive into anything difficult.

&& and == are operators. && is a logical operator that evaluates to true only if both sides of the expression evaluate to true. and == is a comparison operator that evaluates to true if both sides of the expression are equal.

You might want to read through the manual
http://us3.php.net/manual/en/

and maybe read through some beginning tutorials at www.zend.com
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!
Spookster is offline   Reply With Quote
Old 12-17-2003, 06:43 AM   PM User | #5
Goober
New Coder

 
Join Date: Aug 2003
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Goober is an unknown quantity at this point
naw i know the basics of php, and i've read through php.net, but i just can't remember everything cause im still new to this php thing. but thanks man

Last edited by Goober; 12-17-2003 at 12:38 PM..
Goober is offline   Reply With Quote
Old 12-17-2003, 05:27 PM   PM User | #6
DrWeb
New Coder

 
Join Date: Nov 2003
Location: S.F.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
DrWeb is an unknown quantity at this point
Quote:
PHP Code:
$request $_SERVER['REQUEST_URI'];
$method $_SERVER['REQUEST_METHOD']; 

here we declare variables such as $request and $method and assign them to predefined server variables as described in http://www.php.net/manual/en/reserved.variables.php

Quote:
PHP Code:
if ($request == '/myform.php' && $method == 'POST'){
    ....

here we check if both of this variables are true after form has been submitted. If they are - proceed with whatever code you need.
__________________
there are no stupid questions, but there are stupid answers
DrWeb is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:19 AM.


Advertisement
Log in to turn off these ads.