SitePoint Sponsor

User Tag List

Results 1 to 18 of 18
  1. #1
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem with php file

    hi !i have a problem wih my php files when i open it in a browser the php code doesn't work
    for exa mple the code
    <html>
    <body>

    Welcome <?php echo $_POST["fname"]; ?>!<br />
    You are <?php echo $_POST["age"]; ?> years old.

    </body>
    </html>

    the code in php is not show
    please i need help
    thanks

  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2009
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please Check
    1. your php installed proper
    2. var declared correctly

  3. #3
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i install xampp that includes php but nothing.I must install something else?

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It doesn't show anything probably because your $_POST["fname"] and $_POST["age"] don't contain any value.

    You can check if they contain any value by empty(), isset() or simply by if ($_POST["fname"]){ ... } or you can try to display the $_POST array by print_r($_POST) and debug your script.

    Jake

  5. #5
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no because i delete this code and i put just to print with command
    echo "epl";
    but nothing

  6. #6
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It seems that there is a problem somewhere else then. Your script is completely alright.

    Try to run this:

    <?php
    phpinfo();
    ?>

    Does it display anything? It should display something like this:
    http://wiki.gandi.net/_media/en/host...ls/phpinfo.jpg

    Jake

  7. #7
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no does not display that url.

  8. #8
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Then there might be a problem with your installation of xampp. Is Apache server running?

  9. #9
    SitePoint Addict
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you need to use xampp?

    If not, I recommend that you install apache and php using the install files from their sites. The time and effort spent learning how to do this will pay off in the long run.

  10. #10
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes apache is running
    i must use xampp

  11. #11
    SitePoint Addict
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, so assuming you're using localhost with apache, is this your url?
    http://localhost/

    Can you set-up an index.html file with this in it and see it properly?
    http://localhost/index.html
    HTML Code:
    <h1>Hello HTML</h1>
    And then an index.php file with this won't work, correct?
    http://localhost/index.php
    PHP Code:
    <?php
    echo '<h1>Hello PHP</h1>';
    Look at the source code of the http://localhost/index.php url. Do you see the php code as if it were a comment in the source of the page?

  12. #12
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do you know where must i save index.html so i have access with http://localhost/index.html?

  13. #13
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This should be the path on your system (if you are using windows):
    C:\Program Files\xampp\htdocs\

    If you want to run PHP code it needs to be in a file with *.php extension.

    I see that you are newbie to PHP programming. It would be the best if you started with some tutorials first. It is the best to buy some book for beginners.

    www.w3schools.com is a good place to start.

  14. #14
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but i save them in that file

  15. #15
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok thanks very much my friend it works,
    i appreciate

  16. #16
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i pass 2 variables from index.php to check.php file with the command
    header("location:check.php?u1=$myusername,p1=$mypassword");
    i show in url that they pass
    http://localhost/check.php?epl_theodora,theodora
    but how can i get it to check.php

  17. #17
    SitePoint Addict
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try starting with the tutorials jake.polak recommended:
    http://www.w3schools.com/PHP/

  18. #18
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to pass 2 variables via header, you should write it like this:
    header("location:check.php?u1=$myusername&p1=$mypassword");

    There is "&" not "," between variables.

    You can access those variables from URL by calling superglobal array $_GET.

    // Initialization of variables - for security reasons
    $u1 = NULL;
    $u2 = NULL;

    // Get value of variables from URL
    $u1 = $_GET['u1'];
    $u2 = $_GET['p1'];


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
  •