Simple PHP question on Post Get

Discussion in 'PHP' started by Hipto, Jan 6, 2010.

  1. #1
    Hey Guys here is my problem
    First site with 1 text field form. e.g http://xxx.com/mainform/index.php
    I've site e.g http://abc.com/index.php and I iframed http://xxx.com/mainform/index.php on http://abc.com/page2.php

    I've a text field on http://abc.com/index.php too, where i can put in any text(Example ITYPETHIS). The submit button will bring me to page2.php. My aim is that after i click submit, i want 'ITYPETHIS' to be shown on the field at http://xxx.com/mainform/index.php, which is being iframed on page2.php

    I can simply do this with post get, IF they're on the same server/host. My the problem is they're hosted at different place.

    Any good suggestion?
     
    Hipto, Jan 6, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    You can still use $_GET;

    Example, on http://abc.com/index.php have:

    <form action="http://xxx.com/mainform/index.php" method="get">
    Text: <input type="text" name="text" />
    <input type="submit" />
    </form>
    Code (markup):
    And then on http://xxx.com/mainform/index.php, have:

    <?php echo $_GET["text"]; ?>
    PHP:
    If i enter 'ITYPETHIS' on http://abc.com/index.php and click submit, It will display 'ITYPETHIS' on http://xxx.com/mainform/index.php ...

    If you wanted that to be displayed within a field value, you can echo $_GET["text"] within the value of the input tag on http://xxx.com/mainform/index.php.
     
    danx10, Jan 6, 2010 IP
  3. Hipto

    Hipto Peon

    Messages:
    939
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    For some reason, I've to use method="post" on abc.com. Does it works the same too?
     
    Last edited: Jan 7, 2010
    Hipto, Jan 7, 2010 IP
  4. Hipto

    Hipto Peon

    Messages:
    939
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    man u're kidding me. I knew this won't work. You're a novice too LOL
     
    Last edited: Jan 7, 2010
    Hipto, Jan 7, 2010 IP
  5. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #5
    Read -> http://www.weberdev.com/get_example-3859.html

    $_POST is different to $_GET.

    The example i gave is using $_GET, the reason for this is because $_GET passes the submitted values via the url.

    Whereas $_POST doesn't, theirfore i used $_GET in this occasion because the site your submitting to is'nt on the same site.

    So your problem is your using $_POST instead of $_GET, follow my example.
     
    Last edited: Jan 7, 2010
    danx10, Jan 7, 2010 IP
    luckymurari likes this.
  6. luckymurari

    luckymurari Active Member

    Messages:
    629
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    90
    #6
    You need to change your iframe url...

    soemthing like
    <iframe url="http://xxx.com/mainform/index.php?name=<?php echo $_GET['name']; ?>"></iframe>
    
    Code (markup):
    Ofcourse, if its for POST request , you need to do it differently. If you want for POST, then reframe your question.
     
    luckymurari, Jan 7, 2010 IP
  7. Hipto

    Hipto Peon

    Messages:
    939
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Ok I need a solution for POST and danx10 method doesn't work
     
    Hipto, Jan 7, 2010 IP
  8. Bananasphere

    Bananasphere Peon

    Messages:
    76
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    You're not very nice to people who try to help you...

    For POST it would be something like this:

    <iframe url="http://xxx.com/mainform/index.php?name=<?php echo $_POST['name']; ?>"></iframe>
    Code (markup):
    If you can't figure out what to do then read some tutorials or something..
     
    Bananasphere, Jan 7, 2010 IP
    luckymurari likes this.
  9. Hipto

    Hipto Peon

    Messages:
    939
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Thanks. But looking at it. I;m sure u know it would not work :s

    <?php echo $_POST['name']; ?> is from server 1, how does server 2 know what it contains?
     
    Hipto, Jan 9, 2010 IP
  10. Bananasphere

    Bananasphere Peon

    Messages:
    76
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Well of course you would have to call it using $_GET['name'] on server 2. If you're asking how to get post values into an iFrame, you could try to make a new file and use curl to send the post values that way and then link that file into the iframe. Look up curl..
     
    Bananasphere, Jan 9, 2010 IP