Jump to content

Php Post Data...


GITs

Recommended Posts

Hi all...

I'm using a php script to check that an imap connection exists... if it does, i want to re-direct to another page, written in ASP, for further processing. but this re-direct needs to contain post data for the asp page, GET is not an option due to security, and I dont want to use anything other than a base install of php (+extensions which are included in it) if possible... here is what i have so far.

[code]<?php
    $host = "{pastonexch01:143}";
    $connection = imap_open($host, $_POST["user"], $_POST["pass"], OP_HALFOPEN);
    if ($connection) {
      imap_close($connection);
$postdata="user=".$_POST["user"];


      $da = fsockopen("careerslink.paston.ac.uk", 80, $errno, $errstr);
      if (!$da) {
          echo "$errstr ($errno)<br/>\n";
          echo $da;
      }
      else {
          $salida ="POST /login.asp  HTTP/1.1\r\n";
          $salida.="Location: /login.asp\r\n";
          $salida.="User-Agent: PHP Script\r\n";
          $salida.="Content-Type: application/x-www-form-urlencoded\r\n";
          $salida.="Content-Length: ".strlen($postdata)."\r\n";
          $salida.="Connection: close\r\n\r\n";
          $salida.=$postdata;
  echo $salida;
          fwrite($da, $salida);
  echo ("worked :)");
      }
    }
    else{

    }
?>
[/code]

however, this will not re-direct to the next page... i have no idea why because im a php noob...

hoping you can help me, ive been stuck on this for a while now...

GITs
Link to comment
Share on other sites

Hi

First of all php wont redirect once output has been sent,i.e. an echo statement.

Secondly php has built in header transmission. I haven't experimented much with it but it is probably worth a shot:

try replacing:
          $salida ="POST /login.asp  HTTP/1.1\r\n";
          $salida.="Location: /login.asp\r\n";
          echo $salida;

with something like

          header("POST /login.asp  HTTP/1.1");
          header("Location: /login.asp");

Have a read here [url=http://uk.php.net/header]http://uk.php.net/header[/url] for more info.

Hope this is helpful

Cheers,
tdw

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.