Sergiu Costas
Sergiu Costas

Reputation: 560

how to redirect url after submitting a form?

It seems to be a simple but still it is difficult for me to achieve. Let`s make a small example to clarify the situation: There are two files: Form.PHP and Action.PHP

Form.PHP has one Input field with name = "ID" and button SUBMIT

Action.PHP has a script of inserting data in MySQL and in the end next line:

header("location:Form.PHP");

So after the submitting the form, I come back to Form.PHP... This is easy...

Now, I want to achieve - after the submitting the form redirection to Form.PHP?ID=$_POST['ID']

So please help me to modify header("location:Form.PHP"); to redirect to ?ID=$_POST['ID']

Upvotes: 0

Views: 156

Answers (4)

Omkesh Sajjanwar
Omkesh Sajjanwar

Reputation: 1

header("Location: Form.PHP?ID=".$ID);

Upvotes: -1

Preetam
Preetam

Reputation: 618

It's usual URL writing like we normally do. Your code would be

header("location:form.php?id=$id");

make sure you initialize $id = $_POS['id'];

Upvotes: 1

Hanky Panky
Hanky Panky

Reputation: 46900

header("Location: Form.PHP?ID=".$_POST['ID']);

Upvotes: 4

brbcoding
brbcoding

Reputation: 13586

header("location:Form.PHP?ID=" . $_POST['ID']);

Upvotes: 1

Related Questions