pedrobcabral Posted March 26, 2007 Share Posted March 26, 2007 I have a page with a form, and I handle it in the same page. I submit some text and it is displayed. The problem is I want it to be displayed just after I click submit. I'm trying to put a header(link to same page) after the user submit, but it is not working. I can only view the message when I submit, and manually refresh the page on the browser menubar. How should I do? Thank you. Link to comment https://forums.phpfreaks.com/topic/44325-redirection/ Share on other sites More sharing options...
jitesh Posted March 26, 2007 Share Posted March 26, 2007 Can you place your code here to review ? Link to comment https://forums.phpfreaks.com/topic/44325-redirection/#findComment-215261 Share on other sites More sharing options...
pedrobcabral Posted March 26, 2007 Author Share Posted March 26, 2007 <?php if ($_POST[comentario]) { mysql_query("INSERT INTO comentario (comentario, nome, email, evento) VALUES('$_POST[comentario]', '$_POST[nome]','$_POST[email]','$_GET[id]' ) ") or die(mysql_error()); header( "Location: http://localhost:8888/Kulturo/eventos.php?id={$_GET[id]}" ); } ?> This is in the same page where I have the form, and it puts the data into mysql. Link to comment https://forums.phpfreaks.com/topic/44325-redirection/#findComment-215264 Share on other sites More sharing options...
jitesh Posted March 26, 2007 Share Posted March 26, 2007 { ............. ............. header( "Location: http://localhost:8888/Kulturo/eventos.php?id=".$_GET[id]); exit; } Link to comment https://forums.phpfreaks.com/topic/44325-redirection/#findComment-215267 Share on other sites More sharing options...
desithugg Posted March 26, 2007 Share Posted March 26, 2007 <?php if ($_POST['comentario']) { mysql_query("INSERT INTO comentario (comentario, nome, email, evento) VALUES('$_POST[comentario]', '$_POST[nome]','$_POST[email]','$_GET[id]' ) ") or die(mysql_error()); header( "Location: http://localhost:8888/Kulturo/eventos.php?id={$_GET['id']}" ); exit; } else { echo "form nto submit"; } ?> btw i think quotes are always required around $_GET['id'] or arrays like that Link to comment https://forums.phpfreaks.com/topic/44325-redirection/#findComment-215276 Share on other sites More sharing options...
pedrobcabral Posted March 26, 2007 Author Share Posted March 26, 2007 jitesh, that is the same thing but with concatenatio. I've tried the last option but it is still not working, any more help? Thank you. Link to comment https://forums.phpfreaks.com/topic/44325-redirection/#findComment-215296 Share on other sites More sharing options...
desithugg Posted March 26, 2007 Share Posted March 26, 2007 jitesh, that is the same thing but with concatenatio. I've tried the last option but it is still not working, any more help? Thank you. umm try this i misread what you were looking for before <?php if($_GET['formproccess'] == "1") { if ($_POST['comentario']) { mysql_query("INSERT INTO comentario (comentario, nome, email, evento) VALUES('$_POST[comentario]', '$_POST[nome]','$_POST[email]','$_GET[id]' ) ") or die(mysql_error()); header( "Location: http://localhost:8888/Kulturo/eventos.php?id={$_GET[id]}" ); }} echo "<form action='?formproccess=1'>you other input fields or whatever<input type='submit' value='process'></form"; ?> Link to comment https://forums.phpfreaks.com/topic/44325-redirection/#findComment-215373 Share on other sites More sharing options...
tarun Posted March 26, 2007 Share Posted March 26, 2007 Try This: $id = $_GET["id"]; header("Location: http://yourdomain.com/index.php?id=$id"); Link to comment https://forums.phpfreaks.com/topic/44325-redirection/#findComment-215399 Share on other sites More sharing options...
Lethal.Liquid Posted March 26, 2007 Share Posted March 26, 2007 Try This: $id = $_GET["id"]; header("Location: http://yourdomain.com/index.php?id=$id"); if you're doing mysql stuff with an id, to be safe from blind sql injection it should actually be this: $id = $_GET["id"]; settype($id, "int"); header("Location: http://yourdomain.com/index.php?id=$id"); This should work... Link to comment https://forums.phpfreaks.com/topic/44325-redirection/#findComment-215431 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.