PHP, Oracle and HTML

From: Date: Wed, 07 Nov 2001 20:08:12 +0000
Subject: PHP, Oracle and HTML
Groups: php.db 
Request: Send a blank email to php-db+get-14119@lists.php.net to get a copy of this message
Can anyone help me? I don't expect you to run my code or anything, just take a look at the scripts. Somewhere between entering projects and searching for them something goes wrong. Regardless of which keyword radio button I click when entering the project, it always stores it as java when I search for it. However, it does store the right moduleID ??

<! enterProject1.html> <html> <head> <title>Project Database - New Project Idea </title> </head> <body bgcolor="#9966FF" link="lime" vlink="yellow"> <div align="center"><img src="compSciPageBanner.gif"/></div> <h1 align = "center"> Administrative Details </h1> <form action= "http://users.aber.ac.uk/geb97/enterProject1.php4" method= "POST" > <p><font face="arial"> To create the project number first insert today's date e.g. 31st March would be added as 3103, then add a number to represent the number of projects you have added today i.e. if this is the first project you have entered today then add 1, finally add your login e.g. geb97. The final project number should combine all this information together - e.g. 31031geb97 </font></p> <p><pre> <big><b>Project Number: </b></big> <input type= "text" name="projectID" size="20" /></pre></p> <p><pre> <big><b>Project Title: </b></big> <input type= "text" name="title" size="40" /> Maximum of 50 characters </pre></p> <p><pre> <big><b>Principal Originator: </b></big> <input type= "text" name="originator" size="20" /> </pre></p> <p><pre> <big><b>Software/hardware requirements: </b></big> <textarea name="softwareHardware" rows="2" cols="40"> none beyond facilities generally available to students </textarea> </pre></p> <p><pre> <big><b>Special Skills: </b></big> <input type= "text" name="specialSkills" size="35" /> </pre></p> <p><pre> <big><b>Keywords (please check at least one): </b></big><br/> <input type="radio" name="keyword" value="java" checked="checked"><big>Java</big> <input type="radio" name="keyword" value="telematics"><big>Telematics</big> <input type="radio" name="keyword" value="artificialIntelligence"><big>Artificial Intelligence</big> <input type="radio" name="keyword" value="databases"><big>Databases</big> <input type="radio" name="keyword" value="68HC11AssemblyLanguage"><big>68HC11 Assembly Language</big> <input type="radio" name="keyword" value="webDevelopment"><big>Web Development</big> <input type="radio" name="keyword" value="otherProgrammingLanguages"><big>Other Programming Languages</big> </pre></p> <p> <pre> <big><b>Suitability: </b></big> <input type="radio" name="moduleID" value="CS39030" checked="checked"><big>CS39030</big> <input type="radio" name="moduleID" value="CS39110"><big>CS39110</big> <input type="radio" name="moduleID" value="CS49060"><big>CS49060</big> <input type="radio" name="moduleID" value="CSM9060"><big>CSM9060</big> <input type="radio" name="moduleID" value="CSM9260"><big>CSM9260</big> </pre> </p> <p><pre> <big><b>Status: </b></big> <input type="radio" name="status" value="available" checked="checked"><big>Available</big> <input type="radio" name="status" value="allocated"><big>Allocated</big> </pre></p> <p><pre> <big><b>Needs external agreement ? </b></big> <input type="radio" name="externalAgreement" value="no" checked="checked"><big>No</big> <input type="radio" name="externalAgreement" value="yes"><big>Yes</big> </pre></p> <p><pre> <big><b>Background: </b></big> <textarea name="background" rows="4" cols="65"> Enter the project background here </textarea> </pre></p> <p><pre> <big><b>Project Task/s: </b></big> <textarea name="tasks" rows="4" cols="65"> Enter the project task here </textarea> </pre></p> <p><pre> <big><b>Specific Steps: </b></big> <textarea name="steps" rows="4" cols="65"> Enter the specific steps here 1) Step 1 2) Step 2 </textarea> </pre></p> <p><pre> <big><b>References: </b></big> <textarea name="references" rows="4" cols="65"> Enter the references here 1) A book reference 2) A URL web reference </textarea> </pre></p> <p> <div align="center"> <input type="submit" name="submit" value="Click here to enter project"/> <input type="reset" name="reset" value="Click here to reset form and start again"/></div> </p> </form> <div align="center"> <pre> <a href = "http://www.aber.ac.uk">Return to UWA Home Page</a> </div> <div align="center"> <pre> <a href = "http://www.aber.ac.uk/compsci">Return to Computer Science Home Page</a> </pre></div> <div align="center"> <pre> <a href = "mainMenu1.html">Return to Project Database Main Menu</a> </pre></div> </body> </html> <! enterProject1.php4> <html> <head> <title>Project Database - Project Details</title> </head> <body bgcolor="#9966FF" link="lime" vlink="yellow"> <div align="center"><img src="compSciPageBanner.gif"/></div> <?php if ($submit == "Click here to enter project") { // The submit button was clicked! // Get the input and store it in the database. //make a connection to the database PutEnv("ORACLE_HOME=/usr/local/applic/oracle/816"); $connection = OCILogon("geb97","f8s0g99","trdb"); //if a connection to the database is not made output a message if (!$connection) { echo "I couldn't make a connection!"; exit; } //insert values into the table $insert = "insert into PROJECT values ('$projectID', '$moduleID', '$title', '$originator', '$softwareHardware', '$specialSkills', '$status', '$externalAgreement', '$background', '$tasks', '$steps', '$references')"; //formulate the query $query = "select projectID, moduleID, title, originator, softwareHardware, specialSkills, status, externalAgreement, background, tasks, steps, references from PROJECT WHERE projectID='$projectID'"; //parse the two statements $ins_statement = OCIParse ($connection, $insert); $qry_statement = OCIParse ($connection, $query); //execute the insert statement and print error message if there is an error $result = OCIExecute($ins_statement); if (!$result) { echo OCIError($ins_statement)."<p>"; exit; } //execute the query statement OCIExecute($qry_statement); //retrieve the results of the query statement and present them in the following way while (ocifetch($qry_statement)) { //line to tell the user the project has been entered into the database echo "<p><div align=\"center\">The following project has been entered into the Project Database: -</div></p>"; //display the project title echo "<h1 align=\"center\">". OCIresult($qry_statement,'TITLE') ."</h1>"; //display the project number echo "<p><big><b>Project Number: </b></big>". OCIresult($qry_statement, 'PROJECTID')."</p>"; //display the originator echo "<p><big><b>Principal Originator: </b></big>". OCIresult($qry_statement, 'ORIGINATOR') ."</p>"; // no supervisor will be shown because these are not added at the time and a project can have many supervisors //display the software/hardware requirements echo "<p><big><b>Software/Hardware Requirements: </b></big>". OCIresult($qry_statement, 'SOFTWAREHARDWARE') ."</p>"; //display the special skills needed to be used echo "<p><big><b>Special Skills: </b></big>". OCIresult($qry_statement, 'SPECIALSKILLS') ."</p>"; //display which module the project is suitable for echo "<p><big><b>Suitability: </b></big>". OCIresult($qry_statement, 'MODULEID') ."</p>"; //display the status echo "<p><big><b>Status: </b></big>". OCIresult($qry_statement, 'STATUS') ."</p>"; //line to break up text echo "<hr/>"; //a heading for the new section echo "<h2>Description</h2>"; //display the project background echo "<p><big><b>Background: </b></big>"; echo "<p>" . OCIresult($qry_statement, 'BACKGROUND') ."</p>"; //display the project task/s echo "<p><big><b>Project Task/s: </b></big>"; echo "<p>" . OCIresult($qry_statement, 'TASKS'). "</p>"; //display the specific steps echo "<p><big><b>Specific Steps: </b></big>"; echo "<p>" . OCIresult($qry_statement, 'STEPS'). "</p>"; //display the references echo "<p><big><b>References: </b></big>"; echo "<p>" . OCIresult($qry_statement, 'REFERENCES'). "</p>"; //a line to break up the text echo "<hr/>"; //contact email address - couldn't make this into a link because too difficult echo "<p><div align=\"center\"><i>For further information please contact: </i>" . OCIresult($qry_statement, 'ORIGINATOR'). "@aber.ac.uk </div></p>"; //a final line echo "<hr/>"; //the 1st link allows you to register an interest in the project, the 2nd allows you to withdraw the project echo "<p><div align=\"center\"><a href = \"construction.html\"> <img src = \"registerWithProject.jpg\" border = \"0\"/></a> <a href = \"construction.html\"><img src = \"removeProject.jpg\" border = \"0\"/></a></div></p>"; }//end of while statement //commits the information added to the database OCICommit ($connection); //log off the database OCILogoff ($connection); }//end of if statement ?> <! two buttons allow the user to enter another project or email a supervisor> <p><div align="center"><a href = "enterProject1.html"><img src = "anotherProject.jpg" border = "0"/></a> <a href = "construction.html"><img src = "emailSupervisor.jpg" border = "0"/></a></div></p> <div align="center"> <pre> <a href = "http://www.aber.ac.uk">Return to UWA Home Page</a> </div> <div align="center"> <pre> <a href = "http://www.aber.ac.uk/compsci">Return to Computer Science Home Page</a> </pre></div> <div align="center"> <pre> <a href = "mainMenu1.html">Return to Project Database Main Menu</a> </pre></div> </body> </html> <! search1.html> <html> <head> <title>Project Database - Project Search</title> </head> <body bgcolor="#9966FF" link="lime" vlink="yellow"> <div align="center"><img src="compSciPageBanner.gif"/></div> <h1 align="center">Project Search</h1> <form action="http://users.aber.ac.uk/geb97/search1.php4" method="POST"> <h2 align="center">Please select the relevant module and then check the area that may interest you</h2> <h4 align="center"> If, for example, you would like to see all projects that involve Java in some way, check the Java box. You must check at least one box, up to a maximum of 3 keywords</h4> <p> <input type="radio" name="moduleID" value="CS39030" checked="checked"><big>CS39030</big><br/> <input type="radio" name="moduleID" value="CS39110"><big>CS39110</big><br/> <input type="radio" name="moduleID" value="CS49060"><big>CS49060</big><br/> <input type="radio" name="moduleID" value="CSM9060"><big>CSM9060</big><br/> <input type="radio" name="moduleID" value="CSM9260"><big>CSM9260</big><br/> </p> <p> <input type="radio" name="keyword" value="java" checked="checked"><big>Java</big><br/> <input type="radio" name="keyword" value="telematics"><big>Telematics</big><br/> <input type="radio" name="keyword" value="artificialIntelligence"><big>Artificial Intelligence</big><br/> <input type="radio" name="keyword" value="databases"><big>Databases</big><br/> <input type="radio" name="keyword" value="68HC11AssemblyLanguage"><big>68HC11 Assembly Language</big><br/> <input type="radio" name="keyword" value="webDevelopment"><big>Web Development</big><br/> <input type="radio" name="keyword" value="otherProgrammingLanguages"><big>Other Programming Languages</big><br/> </p> <pre> </pre> <!div align="center"><!p><!h4>Please select the number of keyword you have searched for: <!select name="number" size=1> <!option value="1">1<!/option> <!option value="2">2<!/option> <!option value="3">3<!/option> <!/select> <!/h4><!/p><!/div> <pre> </pre> <p> <div align="center"><input type="submit" name="submit" value="Submit"/> <input type="reset" name="reset" value="Reset"/></div> </p> </form> <div align="center"> <pre> <a href = "http://www.aber.ac.uk">Return to UWA Home Page</a> </pre></div> <div align="center"> <pre> <a href = "http://www.aber.ac.uk/compsci">Return to Computer Science Home Page</a> </pre></div> <div align="center"> <pre> <a href = "mainMenu.html">Return to Project Database Main Menu</a> </pre></div> </body> </html> <! search1.php4> <html> <head> <title>Project Database - Search Results</title> </head> <body bgcolor="#9966FF" link="lime" vlink="yellow"> <div align="center"><img src="compSciPageBanner.gif"/></div> <?php if ($submit == "Submit") { // The submit button was clicked! // Get the input and use it to retrieve information from the database. //make a connection to the database PutEnv("ORACLE_HOME=/usr/local/applic/oracle/816"); $connection = OCILogon("geb97","f8s0g99","trdb"); //if a connection to the database is not made output a message if (!$connection) { echo "I couldn't make a connection!"; exit; } //if the number of keywords searched for is one //if ($number == "1") //{ //formulate the query $query = "SELECT PROJECT.originator, PROJECT.title, PROJECT.projectID, PROJECT.status, PROJECT.specialSkills,PROJECT.moduleID FROM PROJECT, PROJKEY, KEYWORD WHERE KEYWORD.keyID=PROJKEY.keyID AND PROJECT.moduleID='$moduleID' AND KEYWORD.keyword='$keyword'"; //} // if the number of keywords searched for is two //elseif ($number == "2") //{ //formulate the query //$query = "SELECT PROJECT.originator, PROJECT.title, PROJECT.projectID, PROJECT.status, //PROJECT.specialSkills,PROJECT.moduleID FROM PROJECT, PROJKEY, KEYWORD WHERE //KEYWORD.keyID=PROJKEY.keyID AND PROJECT.moduleID='$moduleID' //AND KEYWORD.keyword='$keyword'"; //} //if the number of keywords searched for is three //else //{ //formulate the query //$query = "SELECT PROJECT.originator, PROJECT.title, PROJECT.projectID, PROJECT.status, //PROJECT.specialSkills,PROJECT.moduleID FROM PROJECT, PROJKEY, KEYWORD WHERE //KEYWORD.keyID=PROJKEY.keyID AND PROJECT.moduleID='$moduleID' //AND KEYWORD.keyword='$keyword'"; //} //parse the statement $qry_statement = OCIParse ($connection, $query) or die ("Couldn't parse statement"); //execute the query statement OCIExecute($qry_statement) or die ("Couldn't execute query"); //a paragraph break, so the table doesn't appear right at the top of the page echo "<p>"; //create a table into which the results can be placed echo "<table align=\"center\" border=1 cellpadding=8 cellspacing=2 bgcolor=\"silver\">"; echo "<tr valign=\"center\"><th>ORIGINATOR</th><th>TITLE</th><th>PROJECT NUMBER</th><th>AVAILABILITY</th> <th>SPECIAL SKILLS</th></tr>"; //retrieve the results of the query statement and present them in the following way while (ocifetch($qry_statement)) { //insert the results into the table echo "<tr align =\"center\">"; echo "<td>" .OCIresult($qry_statement, 'ORIGINATOR'). "</td>"; echo "<td>" .OCIresult($qry_statement, 'TITLE'). "</td>"; echo "<td>" .OCIresult($qry_statement, 'PROJECTID'). "</td>"; echo "<td>" .OCIresult($qry_statement, 'STATUS'). "</td>"; echo "<td>" .OCIresult($qry_statement, 'SPECIALSKILLS'). "</td>"; echo "</tr>"; }//end of while loop //close table and close the paragraph echo "</table>"; echo "</p>"; //commits the information added to the database OCICommit ($connection); //log off the database OCILogoff ($connection); }//end of if statement //just a note echo "<p><b><div align=\"center\"> If the table above appears empty, this means that no projects fulfil your criteria and you will need to search again </div></b></p>"; //provide a link back to the UWA home page echo "<p><div align=\"center\"> <pre> <a href = \"http://www.aber.ac.uk\">Return to UWA Home Page</a> </pre></div></p>"; //provide a link to the Computer Science Home Page echo "<div align=\"center\"> <pre> <a href = \"http://www.aber.ac.uk/compsci\">Return to Computer Science Home Page</a> </pre></div>"; //provide a link back to the Project Database main menu echo "<div align=\"center\"> <pre> <a href = \"mainMenu1.html\">Return to Project Database Main Menu</a> </pre></div>"; ?> <! end of PHP script> </body> </html>
« previous php.db (#14119) next »