Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good Day

I have a question
i want to pass a value through hyper link to other page like
apply
and in next page i.e. somepage.php
i have a form that will use value which is sent.
$somevar = $_GET['id'];
now will input fields in this page which is a form.
issue is that when i submit the page the page gets refreshed and $somevar
gets empty when the form is submitted.

also i want to display the success message or error message after form is submiited
and then redirect to page from where link (id) was sent.
this is seniorio

1. main page contains no of jobs when i click apply link
apply
2. apply page is form page that inputs user data e.g.

form name="abc" action="result.php" method="POST"
name:
age:
address:
email: etc

/Form

3. result.php
here i perform validation then, save data in database
insert into tablename(fied1,field2...) values (val1,val2,...);
now i want to show success message using java script
echo "Application Submitted Successfully";
header("Location:mainpage.php");

Issue
issue is that record is saved but alert message is not displayed instead it goes to mainpage.php without showing any message;

What I have tried:

i tried many things but nothing happend
Posted
Updated 16-Apr-18 21:57pm
v3

1 solution

The parameter is part of the URL and must be therefore within the quotation marks:
HTML
<a href="somepage.php?id=2">Link Text</a>

If you need to go back to the page from where this one was opened, you can pass it as parameter too:
HTML
<a href="somepage.php?id=2&back=sourcepage.php">Link Text</a>
For alternative methods (when no parameters has been passed) see this SO thread:
php - Go Back to Previous Page - Stack Overflow[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900