cleary1981 Posted July 29, 2008 Share Posted July 29, 2008 Hi I have two pages where I want to pass a value from one page to the next. I want to pass "proj_id_edit".Heres my first page. <?php if ($_COOKIE["auth"] == "1") { } else { //redirect back to login form if not authorised header ("Location: loginform.html"); exit; } ?> <html> <head> <title>TES - Business Developement</title> <link rel="icon" href="/favicon.ico" type="image/x-icon" /> <link rel="stylesheet" type="text/css" href="style.css" /> <style type="text/css"> </style> <script language="javascript" src="list_companies.php"></script> <script type="text/javascript" src="text-utils.js"> </script> <script type="text/javascript" src="request.js"> </script> <script type="text/javascript"> var p_id; window.onload = function() { fillCompany(); } function get_Company() { fillProject(); var comp = document.getElementById("Company").value; var url = "lookupAccNo.php?comp=" + escape(comp); request.open("GET", url, true); request.onreadystatechange = updateAccNo; request.send(null); } function updateAccNo() { if (request.readyState ==4) { var accountnumber = request.responseText; var x = document.getElementById("acc_no"); replaceText(x, accountnumber); } } function get_project() { var proj = document.getElementById("project").value; var url = "lookupProjId.php?proj=" + escape(proj); url = url + "&dummy=" + new Date().getTime(); request.open("GET", url, true); request.onreadystatechange = updateProj; request.send(null); } function updateProj() { if (request.readyState == 4) { var returned = request.responseText; var splitResult = returned.split("%"); var r_proj_id = splitResult[0]; var r_projName = splitResult[1]; var r_form = splitResult[2]; var r_access = splitResult[3]; var r_cable = splitResult[4]; var r_ip = splitResult[5]; var r_fault = splitResult[6]; var r_comp = splitResult[7]; var r_pman = splitResult[8]; var r_deadline = splitResult[9]; document.company1.proj_id_edit.value = r_proj_id; document.company1.projName_edit.value = r_projName; document.company1.comp_edit.value = r_comp; document.company1.access_edit.value = r_access; document.company1.cable_edit.value = r_cable; document.company1.ip_edit.value = r_ip; document.company1.fault_edit.value = r_fault; document.company1.iform_edit.value = r_form; document.company1.pman_edit.value = r_pman; document.company1.deadline_edit.value = r_deadline; } } function updateProjectDetails() { var uproj_id = document.getElementById("proj_id_edit").value; var uaccess = document.getElementById("access_edit").value; var ucable = document.getElementById("cable_edit").value; var uip = document.getElementById("ip_edit").value; var ufault = document.getElementById("fault_edit").value; var uform = document.getElementById("iform_edit").value; var upman = document.getElementById("pman_edit").value; var udl = document.getElementById("deadline_edit").value; var url = "updateProjectDetails.php?uproj_id=" + escape(uproj_id) + "&uaccess=" + escape(uaccess) + "&ucable=" + escape(ucable) + "&uip=" + escape(uip) + "&ufault=" + escape(ufault) + "&uform=" + escape(uform) + "&upman=" + escape(upman) + "&udl=" + escape(udl); url = url + "&dummy=" + new Date().getTime(); request.open("GET", url, true); request.onreadystatechange = showConfirmation; request.send(null); } function showConfirmation () { if (request.readyState == 4) { var xx = document.getElementById("xx"); ss = document.createTextNode("Update complete"); xx.appendChild(ss); var t=setTimeout("xx.removeChild(ss)",2000); //display message for 2seconds then removes it } } function openDesignMode() { window.open('designmode.php', 'Design View', 'statusbar=yes'); } </script> </head> <body> <form name="company1" action="updateProjectDetails.php" method="POST"> <fieldset> <legend>1. Select Company (or add company to database then press F5 to refresh list)</legend> <table border=0 width=100%><tr><td width=45%><div><label for="Company" id="label1">Company Name</label> <SELECT id="Company" NAME="Company" onChange="get_Company()"> <Option value="">Existing Company</option> </SELECT></div></td> <td width=45%><div><label for="acc_no" id="label2">Account Number</label> <span id="acc_no"> </span></div></td> <td><input type = "button" value = "newCompany" id="comp_button" onClick = "window.open('newcompany.php', 'NewCompany', 'width=400, height=400 statusbar=yes')"> </td></tr></table> </fieldset> <fieldset> <legend>2. Select an existing project or create a new project</legend> <table border=0 width=100%><tr><td width=45%><div><label for="project">Project Name</label> <SELECT id="project" NAME="project" onChange="get_project();"> <Option value="">Existing Project</option> </SELECT></div></td> <td width=45%><div> <span id="proj_id1"> </span></div></td> <td><input type = "button" value = "New Project" onClick = "window.open('newproject.php', 'NewProject', 'width=400, height=400 statusbar=1, status=yes')"> </td></tr></table> </fieldset> <fieldset> <legend>3. Update project details (if required)</legend> <table width=100% border=0> <tr> <td><label for="proj_id_edit">Project ID</label> <input type = "text" value = "" disabled name = "proj_id_edit" id = "proj_id_edit" onChange="setProject"></td> <td><label for="projName_edit">Project Name</label> <input type = "text" value = "" disabled name = "projName_edit" id = "projName_edit"></td></tr> <tr><td><label for="comp_edit">Company Name</label> <input type = "text" value = "" disabled name = "comp_edit" id = "comp_edit"></td> <td><label for="access_edit">Access</label> <input type = "text" value = "" name = "access_edit" id = "access_edit"></td></tr> <tr><td><label for="cable_edit">Cable Entry</label> <input type = "text" value = "" name = "cable_edit" id = "cable_edit"></td> <td><label for="ip_edit">IP Rating</label> <input type = "text" value = "" name = "ip_edit" id = "ip_edit"></td></tr> <tr><td><label for="fault_edit">Fault Rating</label> <input type = "text" value = "" name = "fault_edit" id = "fault_edit"><span>KW/sec</span></td> <td><label for="iform_edit">Form</label> <input type = "text" value = "" name = "iform_edit" id = "iform_edit"></td></tr> <tr><td><label for="pman_edit">Project Manager</label> <input type = "text" value = "" name = "pman_edit" id = "pman_edit"></td> <td><label for="deadline_edit">Tender Deadline</label> <input type = "text" value = "" name = "deadline_edit" id = "deadline_edit"></td> </tr> <tr><td><input type="button" value="Update" name="update" onClick="updateProjectDetails()"> <div id="xx"></div></td></tr></table> </fieldset> <fieldset> <legend>4. Proceed to Design Mode</legend> <input type="button" value="Design Mode" onClick = "window.open('designmode.php?p_id = {document.getElementById("proj_id_edit").value}', '', 'width=1280, height=700, resizable=yes, statusbar=yes')"> </fieldset> </form> </body> </html> Heres the second <?php if ($_COOKIE["auth"] == "1") { } else { //redirect back to login form if not authorised header ("Location: loginform.html"); exit; } ?> Quote Link to comment Share on other sites More sharing options...
d.shankar Posted July 29, 2008 Share Posted July 29, 2008 Use this <?php @extract($_POST); echo $proj_id_edit; // your value for this variable will be printed here if ($_COOKIE["auth"] == "1") { } else { //redirect back to login form if not authorised header ("Location: loginform.html"); exit; } ?> Quote Link to comment Share on other sites More sharing options...
cleary1981 Posted July 29, 2008 Author Share Posted July 29, 2008 does this go into the second page? Quote Link to comment Share on other sites More sharing options...
d.shankar Posted July 29, 2008 Share Posted July 29, 2008 Did u try first ? Quote Link to comment Share on other sites More sharing options...
cleary1981 Posted July 29, 2008 Author Share Posted July 29, 2008 I have placed it in first. Havnt recieved any errors. How do I check it has passed to second page? Quote Link to comment Share on other sites More sharing options...
d.shankar Posted July 29, 2008 Share Posted July 29, 2008 The code which i have given should be added to the second page. Does your first page contain a form and this variable proj_id_edit. Quote Link to comment Share on other sites More sharing options...
cleary1981 Posted July 29, 2008 Author Share Posted July 29, 2008 ok. I have placed the code in the second page and used the below line to show the output which is not showing anything <span>show here<?php $proj_id_edit; ?></span> Quote Link to comment Share on other sites More sharing options...
d.shankar Posted July 29, 2008 Share Posted July 29, 2008 Hmm you are lost This is First page <?php /* Your cookie authentication goes here */ <form action="page2.php" method="post"> <input type="submit" value="test" name="proj_id_edit"> </form> ?> This is just an illustration code.. Add your variable proj_id_edit into the form u have in the first page. The page2.php is the code which i posted previously. Quote Link to comment Share on other sites More sharing options...
cleary1981 Posted July 29, 2008 Author Share Posted July 29, 2008 sorry.. just back there. I got it thanks for your help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.