Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Aug 2003
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question PHP Forms Question

    how can i make a PHP file that will only accept "POST" commands in a form, from certian file(s)?

  • #2
    New Coder
    Join Date
    Nov 2003
    Location
    S.F.
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    New Coder
    Join Date
    Aug 2003
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #4
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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

  • #5
    New Coder
    Join Date
    Aug 2003
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    New Coder
    Join Date
    Nov 2003
    Location
    S.F.
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •