Jump to content

[SOLVED] Redirect with header?


Vampen

Recommended Posts

Have a mail script, and after the mail has been sendt i would like the browser to redirect the user to the previous page. Anyone know a good way to do this?

 

This is my code now and this dont work!

 

<?php
$id = $_GET['id'];
function kobleTil($databasenavn) {

$vert = "localhost";
$bruker = "xxx";
$passord = "xxx";
$tilkobling = mysql_connect($vert, $bruker, $passord);
if (!$tilkobling) {
		die("Kunne ikke koble til: " . mysql_error());
}

$valgtDB = mysql_select_db($databasenavn, $tilkobling);
if (!$valgtDB) {
		die("Kunne ikke bruke databasen: " . mysql_error());
}
return $tilkobling ;
}

define("TILBAKE",
				"<p><a href='javascript:history.go(-1)'>Tilbake</a>");
?>	

<?php 


$tilkobling = kobleTil("xxx"); //Her hentar eg fram igjen funksjonen

$sql = "SELECT * from annonse,bruker where idannonse = $id and bruker.idbruker=annonse.bruker_idbruker";  

$resultat = mysql_query($sql, $tilkobling);	

$rad = mysql_fetch_array( $resultat );
$mot_navn = $_POST['mot_navn'];
$mot_epost = $_POST['mot_epost'];
$annonse = "http://www.bustad.net/vis_ann.php?id=".$id."";

$id = $_GET['id'];

mail("$mot_epost","Du har motatt ei melding on annonse fra xxx","Kjære $mot_epost. \n\nDu har fått ei melding om ei annonse du finn på xxx. \n\n Du finn annonsa her:  $annonse.\n\nMeldinga er sendt av:\n\n$mot_navn\n\n");  
echo "<br><br><center><IMG SRC='grafikk/ANNONSA.jpg'></center>";


?>

<?php
header("Location: http://xxx/vis_ann.php?id=". $id ."");
?>

Link to comment
https://forums.phpfreaks.com/topic/38699-solved-redirect-with-header/
Share on other sites

that would work, papaface. the only thing i would change is to use long tags. short tags may not be supported on every php.ini.

<SCRIPT language="JavaScript">
<!--
window.location="somepage.php?id=<?php $_GET['id']; ?>";
//-->
</SCRIPT>

 

i would also use $_GET. but that's just me.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.