Professional Web Applications Themes

call function in different php files - PHP Development

Hi, I wrote a php project 2 years ago. I am totally lost right now. what is differnt between $userName, $_GET['userName'] and $_REQUEST['userName']? In my past project, I remember i can use $userName as a variable, but i dont know why I cannot use it again because of using different version of php and apache? What is different between "printf", "print" and "echo"? Can you guys help me fix my a little project too? Thanks Two files testing1.php <?php require ('testing.php'); if(!$_REQUEST['submit1']) { MainFrame(); } else if ($submit1 == "Receiving") { print $_REQUEST['username']; } else print $_REQUEST['sumbit1']; ?> testing.php <?php ...

  1. #1

    Default call function in different php files

    Hi, I wrote a php project 2 years ago. I am totally lost right now.
    what is differnt between $userName, $_GET['userName'] and
    $_REQUEST['userName']? In my past project, I remember i can use
    $userName as a variable, but i dont know why I cannot use it again
    because of using different version of php and apache? What is
    different between "printf", "print" and "echo"? Can you guys help me
    fix my a little project too? Thanks

    Two files
    testing1.php
    <?php

    require ('testing.php');

    if(!$_REQUEST['submit1'])
    {

    MainFrame();
    }
    else if ($submit1 == "Receiving")
    {
    print $_REQUEST['username'];
    }
    else

    print $_REQUEST['sumbit1'];

    ?>

    testing.php
    <?php

    function MainFrame()
    {
    print ("<form action = "testing1.php" method="POST">
    <input type ="text" name="username"><br>
    <input type ="submit" name="submit1" value="Receiving">
    <input type ="submit" name="submit1" value="Invenory">
    <input type ="submit" name="submit1" value="Assembly">
    <input type ="submit" name="submit1" value="Tracking">
    <input type ="submit" name="submit1" value="Reports">
    <input type ="submit" name="submit1" value="Setup">
    </form>
    ")

    ?>

    I get these errors:

    P error: p error, unexpected T_STRING in c:\program
    files\easyphp1-7\www\testing.php on line 5

    Notice: Undefined index: submit1 in c:\program
    files\easyphp1-7\www\testing1.php on line 6

    Fatal error: Call to undefined function: mainframe() in c:\program
    files\easyphp1-7\www\testing1.php on line 9

    Thanks,
    Krista
    Krista Guest

  2. #2

    Default Re: call function in different php files

    "Perhaps the most controversial change in PHP is when the default value for
    the
    PHP directive register_globals went from ON to OFF in PHP 4.2.0. "

    http://pl2.php.net/register_globals

    IMHO U have 2 ways

    1. Use $_GET, $_POST, $_SERVER
    or
    2. Set the register_globals=on in php.ini

    :) i hope this helps you out :)


    websafe Guest

  3. #3

    Default Re: call function in different php files

    Hi Krista,
     

    The GET-Variables are submitted like this:
    http://domain.tld/file.php?variable=value

    So $_GET['variable'] contains "value".
     

    If the option of register_globals is switched on in the php.ini you can
    use $variable instead of $_GET['variable'], too.
    If it is switched off, like the default setting in the newer php
    versions, you can't.
     

    Difference between echo and print:
    http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40

    printf is to print a formatted string.
    http://de2.php.net/manual/en/function.printf.php

    Saludo
    Paul.
    Paul Guest

  4. #4

    Default Re: call function in different php files

    Krista wrote: 

    printf is formatted print, as:
    printf("Error %s occurred on line %d", $error_desc, $error_line);

    print and echo are close to the same thing. IIRC, print returns but
    echo doesn't.

    Keith Guest

  5. #5

    Default Re: call function in different php files

    Keith Bowes <me> wrote in message news:<dLnCb.60$private.usenetserver.com>... 
    >
    > printf is formatted print, as:
    > printf("Error %s occurred on line %d", $error_desc, $error_line);
    >
    > print and echo are close to the same thing. IIRC, print returns but
    > echo doesn't.[/ref]

    Hi,
    I still get a problem if i set global_register to on. I cannot pass
    the value to the different php files. The example as following:

    Testing.php
    <?php

    function abc()
    {
    print("<form action = "testing1.php" method="GET">
    <input type ="text" name="username"><br>
    <input type ="submit" name="submit1" value="Receiving">
    <input type ="submit" name="submit1" value="Inventory">
    </form>
    }
    ?>
    Testing1.php
    <?php

    require ("testing.php");

    if(!$sumbit1)
    {
    abc();
    }
    else if ($submit1 == "Receiving")
    {
    print "Receiving";
    }
    else if ($submit1 == "Inventory")
    {
    print "Inventory";
    }
    else
    {
    print "Thank";
    }
    ?>
    Then i am tring to run it in IE: http://localhost/testing1.php
    but the result is nothing on the IE.
    Therefore, what is the problem in my problem or my config has a
    problem?
    Thanks,
    Krista
    Krista Guest

  6. #6

    Default Re: call function in different php files

    Krista wrote: 
    _____ $submit1 ___

    Perhaps this is better? :-)


    put
    <?php
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
    ?>

    at the very beginning of the scripts you're writing/debugging so that
    php itself will tell you about some mistakes (with its notices and
    warnings).


    Happy Coding
    --
    --= my mail box only accepts =--
    --= Content-Type: text/plain =--
    --= Size below 10001 bytes =--
    Pedro Guest

  7. #7

    Default Re: call function in different php files

    Keith Bowes <me> wrote in message news:<dLnCb.60$private.usenetserver.com>... 
    >
    > printf is formatted print, as:
    > printf("Error %s occurred on line %d", $error_desc, $error_line);
    >
    > print and echo are close to the same thing. IIRC, print returns but
    > echo doesn't.[/ref]

    Hi,
    Even though I changed the global_register to on in php.int . I still
    cannot use $username. Anybody can help?

    Thanks,
    Krista
    Krista Guest

Similar Threads

  1. Function call
    By Ric in forum ASP.NET General
    Replies: 6
    Last Post: March 25th, 03:19 PM
  2. How do I call a function?
    By Donn Gross in forum Adobe Acrobat Windows
    Replies: 7
    Last Post: May 5th, 10:43 PM
  3. How do I call an outer function from a class method function?
    By Phil Powell in forum PHP Development
    Replies: 5
    Last Post: October 16th, 09:56 AM
  4. Call function from <form>
    By Ricki Susic in forum PHP Development
    Replies: 2
    Last Post: September 27th, 12:57 AM
  5. Q: How to time out a function call?
    By Nikolai Chuvakhin in forum PHP Development
    Replies: 1
    Last Post: August 24th, 02:14 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139