1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Some Newbie questions.. pls help me><

Discussion in 'PHP' started by miraclez, Nov 12, 2007.

  1. #1
    i need to pass the variable from another url..
    like example i got 2 file host on different domain.. a and b.php
    and when i run b.php.. the variable from a.php is not passing to b.php..

    a.php

    <?php

    $var1 = "this is var1";

    $var2 = "and this is var2";

    ?>

    ----------------------------------------

    b.php

    <?php

    include ('http://www.example.com/a.php');

    echo $var1;

    echo $var2;

    ?>


    is that something wrong with the coding?... can anyone help me out..Please ><
     
    miraclez, Nov 12, 2007 IP
  2. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #2
    there are many ways to pass variable to other pages

    try this one, parameter handling

    page1.php
    
    $var=foo;
    $var2=foo2;
    <a href="page2.php?var=foo&var2=foo2"></a>
    
    PHP:
    page2.php
    
    $var = $_GET['var'];
    $var2 = $_GET['var2'];
    echo $var . " " . $var2; 
    
    PHP:
    i also used session for this
    page1.php
    
    session_start();
    $var = foo;
    $var2 = foo2;
    $_SESSION['var'] = $var;
    $_SESSION['var2'] = $var2;
    
    PHP:
    page2.php
    
    session_start();
    echo $_SESSION['var'] . " " . $_SESSION['var2'];
    
    PHP:
    or by form
    page1.php
    
    <form method=POST action="page2.php">
    <input type="hidden" name="var" value="foo">
    <input type="hidden" name="var2" value="foo2">
    <input type="submit" value="submit">
    </form>
    
    PHP:
    page2.php
    
    $var = $_POST['var'];
    $var2 = $_POST['var2'];
    echo $var . " " . $var2;
    
    PHP:
    hope this helps, or give you an idea
     
    bartolay13, Nov 13, 2007 IP
  3. mariuspompier

    mariuspompier Peon

    Messages:
    323
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This type of include will never work, because you need to insert the dir path not the web one.

    The post above has many ways that you can deal with your problem. :)

    Good Luck!
     
    mariuspompier, Nov 13, 2007 IP
  4. Lord Fire

    Lord Fire Banned

    Messages:
    299
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    use this one


    <?php
    session_start();
    $var1 = "this is var1";
    
    $var2 = "and this is var2";
    
    ?>
    
    ----------------------------------------
    
    b.php
    
    <?php
    
    include "a.php";
    
    echo $var1;
    
    echo $var2;
    
    ?>
    PHP:
     
    Lord Fire, Nov 13, 2007 IP
  5. Extazy

    Extazy Member

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #5
    as i know "session_start();" must be on b.php too.. and he must use $_SESSION['var1']... or im wrong)
     
    Extazy, Sep 18, 2012 IP
  6. alexkboorman

    alexkboorman Peon

    Messages:
    70
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #6
    you can use the session syntax or declare globals but it's notable to mention that he needs to ensure he starts his sessions at the top of each page, directly after <?php. It's also good practice to close/destroy when no longer needed.
     
    alexkboorman, Sep 23, 2012 IP
  7. jimcarry464

    jimcarry464 Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    One way to save big on your new website is by having your web designer use a ready-made theme. At this pointing you might be thinking, "hold on, templates make for bland sites that provide no wow factor". You are right, this is true of templates that allow anyone with a mouse to create a webpage. If you dig deeper into the web and find the right web designer, they can show you thousands of amazing templates sure to impress you and your visitors. Unlike the bland templates we talked about, these themes create high quality sites and take a certain level of skill to implement.
    Although templates are great and can save you money, they are not always right for your business. Your company might not always fit in to a pre-made theme. Here is a general rule to follow to know if your company needs a custom design or can use a theme. Restaurants, boutiques and small niche companies often have trouble finding a theme to fit their unique personality. If you have a storefront and are marketing directly to the consumer, than you may need a design distinct as you. Remember this is a general rule and does not hold true all the time; it is just a guide to follow, so be sure to ask. However, if your business model is primarily B2B or your place of business is in an office park, industrial area or high-rise building, than you are usually the perfect candidate for a using a theme.
    If you choose a theme, make sure your designer tailors the theme around your specific needs. After all that is partially why you hired them. Ask yourself this question, "What do I want my website visitors to do?" Are they there to buy something, become educated about my product, contact me for a quote or sign up for my mailing list? This is known as your "call to action" and your site should be developed around this action. Too often website owners do not ask themselves this question and their site reflects it.
    Finally remember this, think like your customer. Do not assume they know what your business is when they get to your site. Clearly define what you do on the front page. This can be done with words and pictures. Do not overload the page with industry jargon and technical information. Remember your customer may be searching for "new brakes for my bike" and you page may read "Shimano XT-100" There is no faster way to lose a customer than having them land on your site to be instantly confused. Make sure you develop great content for you website but more importantly make sure your web designer understands yours business and your customers.
    By understanding the concepts above you can be armed with the information to help you choose your future web designer.
     
    jimcarry464, Sep 23, 2012 IP
  8. pxranger

    pxranger Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    include ('http://www.example.com/a.php');

    Won't that never work, since it'll just translate it to HTML?
     
    pxranger, Sep 24, 2012 IP
  9. pxranger

    pxranger Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    pxranger, Sep 24, 2012 IP