Results 1 to 7 of 7

Thread: [RESOLVED] Pass Variables from One Page to Another

  1. #1

    Thread Starter
    Hyperactive Member samsyl's Avatar
    Join Date
    Jun 2001
    Location
    London
    Posts
    338

    [RESOLVED] Pass Variables from One Page to Another

    i m trying to pass variable from one page to another but this variable stay empty

    here is my full code -

    page.php
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>page</title>
    </head>
    <body>
    
    <form name="form1" action="page1.php" method="post">
     <input type="text" name="var1" value="">
     <input type="submit" name="submit" value="submit">
    </form>
    
    </body>
    </html>
    page1.php
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>page1</title>
    </head>
    <body>
    
    <?
    $variable_from_page = $_POST['var1'];
    echo($variable_from_page);
    ?>
    
    </body>
    </html>
    Last edited by samsyl; May 29th, 2009 at 05:56 PM.

  2. #2
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Pass Variables from One Page to Another

    Chances are your shorttags aren't being parsed.

    Replace <? with <?php

    Example:
    PHP Code:
    <?php

    //code goes here

    ?>

  3. #3

    Thread Starter
    Hyperactive Member samsyl's Avatar
    Join Date
    Jun 2001
    Location
    London
    Posts
    338

    Re: Pass Variables from One Page to Another

    Its not working too. I m using Apache 1.3 and PHP4. I cant understand wer is the mistake.
    Thanks for help

  4. #4
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Pass Variables from One Page to Another

    There is no error with the code, it works fine. If you run a page with just

    PHP Code:
    <?php
    echo phpinfo();
    ?>
    Does it work? It sounds like there may be issues with PHP in your apache install.

  5. #5

    Thread Starter
    Hyperactive Member samsyl's Avatar
    Join Date
    Jun 2001
    Location
    London
    Posts
    338

    Re: Pass Variables from One Page to Another

    i jst downloaded 'ZZEE PHP GUI' for test and code is working fine.
    something wrong with my apache 1.3
    do i need the latest apache?

  6. #6
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Pass Variables from One Page to Another

    Apache doesn't seem to be the problem. Your web service is running fine or else the HTML wouldn't appear. You may need to install PHP or upgrade your service.

    If you want to save yourself some trouble, I suggest just downloading WAMP for this kind of testing.

    WAMP URL: http://www.wampserver.com/en/

  7. #7

    Thread Starter
    Hyperactive Member samsyl's Avatar
    Join Date
    Jun 2001
    Location
    London
    Posts
    338

    Re: Pass Variables from One Page to Another

    Its an excellent software. Everything working nicely. Thanks for help

Posting Permissions

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



Click Here to Expand Forum to Full Width