Vampen Posted February 15, 2007 Share Posted February 15, 2007 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 More sharing options...
papaface Posted February 15, 2007 Share Posted February 15, 2007 Javascript: <SCRIPT language="JavaScript"> <!-- window.location="somepage.php"; //--> </SCRIPT> Link to comment https://forums.phpfreaks.com/topic/38699-solved-redirect-with-header/#findComment-185877 Share on other sites More sharing options...
Vampen Posted February 15, 2007 Author Share Posted February 15, 2007 Javascript: <SCRIPT language="JavaScript"> <!-- window.location="somepage.php"; //--> </SCRIPT> I need the value in $id in the link so i dont know if i could use this one.. Link to comment https://forums.phpfreaks.com/topic/38699-solved-redirect-with-header/#findComment-185878 Share on other sites More sharing options...
papaface Posted February 15, 2007 Share Posted February 15, 2007 <SCRIPT language="JavaScript"> <!-- window.location="somepage.php?id=<?=$id;?>"; //--> </SCRIPT> That would work Link to comment https://forums.phpfreaks.com/topic/38699-solved-redirect-with-header/#findComment-185879 Share on other sites More sharing options...
boo_lolly Posted February 15, 2007 Share Posted February 15, 2007 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. Link to comment https://forums.phpfreaks.com/topic/38699-solved-redirect-with-header/#findComment-185884 Share on other sites More sharing options...
Vampen Posted February 15, 2007 Author Share Posted February 15, 2007 <SCRIPT language="JavaScript"> <!-- window.location="somepage.php?id=<?=$id;?>"; //--> </SCRIPT> That would work Yep it did! Thx alot! Link to comment https://forums.phpfreaks.com/topic/38699-solved-redirect-with-header/#findComment-185885 Share on other sites More sharing options...
papaface Posted February 15, 2007 Share Posted February 15, 2007 @Vampen Np @boo_lolly Yeah, I would use get if i was referring to a URL, but I think the $id comes from somewhere in the script. I never rely on register globals being enabled, and even if it was i wouldnt use it. Link to comment https://forums.phpfreaks.com/topic/38699-solved-redirect-with-header/#findComment-185886 Share on other sites More sharing options...
boo_lolly Posted February 15, 2007 Share Posted February 15, 2007 @boo_lolly Yeah, I would use get if i was referring to a URL, but I think the $id comes from somewhere in the script. I never rely on register globals being enabled, and even if it was i wouldnt use it. agreed. Link to comment https://forums.phpfreaks.com/topic/38699-solved-redirect-with-header/#findComment-185887 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.