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
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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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