Jump to content

Redirection


pedrobcabral

Recommended Posts

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

 

<?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

<?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

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

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

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.