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. Quote Link to comment 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 ? Quote Link to comment 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. Quote Link to comment 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; } Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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"; ?> Quote Link to comment 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"); Quote Link to comment 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... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.