FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

changing output but not action="filename.php" ...H

 


Atishay
Hello,

I want to submit a form to a page say filename.php but want to show my custom output and not of filename.php

Like the filename.php on submitting gives the output "Account success fully created!" but I want some other page to appear say "output.html"

Can anyone suggest me some solution ?

P.S. - I want to execute filename.php on submission of form too
---------
hexkid
Atishay wrote:
Hello,

I want to submit a form to a page say filename.php but want to show my custom output and not of filename.php

Like the filename.php on submitting gives the output "Account success fully created!" but I want some other page to appear say "output.html"

Can anyone suggest me some solution ?

P.S. - I want to execute filename.php on submission of form too
---------

Do your thing in filename.php (no output!) then redirect.
Code:
// filename.php
$newurl = 'http://www.example.com/default.html';
foreach ($_POST as $k=>$v) {
  if ($k != $v) $newurl = 'http://www.example.com/output.html';
}
header('Location: ' . $newurl);
exit('Redirected to <a href="'.$newurl.'">'.$newurl.'</a>.')


If you need to pass information from filename.php to output.html (should be processed by php too, maybe it's better to make it output.php?) use session variables or URL parameters.
sonam
Yeah,
redirect from filename.php is the best way for you problem. Also you can set one variable (e.g. $output = "Account success fully created!" ), sent this variable with session on new url and print it out.

Sonam
Atishay
But the filename.php is not hosted at my server. I cant edit it. Is there any other way out ?
hexkid
Atishay wrote:
But the filename.php is not hosted at my server. I cant edit it. Is there any other way out ?

cURL is an option.

Code:
<?php
### get data from user
// ...

### submit to outside server (filename.php) with cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'http://outside.com/filename.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'u=newname&p=password');
$outside_data = curl_exec($ch);
curl_close($ch);

### deal with data from outside server
// ... using $outside_data

### generate your output (or redirect)
// ...
?>
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.