Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hey, I want to open a php page with data sent from the page before. The problem I have it the link to get to the new page is in a database and is being listed using pdo.
PHP
echo '<li  önClick = "headerMove();">'.$projectName.'<a href = "#"><img src = "../img/setting.png"></a><span id = "lastEdited">Last Edited: '.$lastEdited.'</span><span id = "sharedOption">'.$shared.'</span></li>';


if you look there is a onclick listener right at the beginning, I am wondering how I can get that to open up a project page I have set up but along with that bring data along to the new page.

I have tried calling a separate javascript function
JavaScript
function headerMove() {
<?php
header("Location: project.php");
?>
}

but the php code runs before the javascript function is being called.

Please Help :)
Posted

Calling PHP code within javascript does not make sense.
You need to use JavaScript, something like this:
JavaScript
function headerMove() {
  location.href = "project.php";
}
 
Share this answer
 
Have you tried creating a php session and then storing your data in $_SESSION variables? All target pages must, of course, also be part of the session.

To start a session, the following must be the FIRST item on the page, allowing only to come before it if it's on the page.

<?php session_start(); ?>

You can then load your values into session variables which are global to the session.

 
Share this answer
 
v2

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