nvidia Posted March 16, 2007 Share Posted March 16, 2007 Hi i have a html form called connect.html where i enter my username and password. After i have done that i hit the submit button. If i am successful, a message saying User [ w1009048] successfully connected which is in my handler1.php . I then click on a link called table which redirects me to another page (table.php) and SHOULD display the customer id and name from my customer table(database). When i click on the table link i get the following statmetents: Notice: Undefined index: txtun in /home/eland/u1/kbccs/w1009048/public_html/RAD/Examples/handler1.php on line 6 Notice: Undefined index: txtpw in /home/eland/u1/kbccs/w1009048/public_html/RAD/Examples/handler1.php on line 7 Warning: ocilogon(): OCISessionBegin: Error while trying to retrieve text for error ORA-01017 in /home/eland/u1/kbccs/w1009048/public_html/RAD/Examples/handler1.php on line 16 Error: Could not connect to Oracle connect.html <html> <head> <title> Connecting To A Database </title> </head> <body> <form action="handler1.php" method="POST"> Your username: <input type="text" name="txtun" value=" " /><br> Your password: <input type="password" name="txtpw" value=" " /> <br> <input type="submit" name="GO" /> </form> </body> </html> handler1.php <html> <?php // get variables from form $un = $_POST['txtun']; $pw = $_POST['txtpw']; $db = '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = squirrel.wmin.ac.uk) (PORT = 1521)) (CONNECT_DATA = (SID = ORA8) (SERVER = DEDICATED)))'; // establish connection if($c=OCILogon($un, $pw, $db) ) { print "User [$un] successfully connected <br> "; OCIlogoff($c); } else { Exit("Error: Could not connect to Oracle"); table.php <?php require('handler1.php'); $cname = $_POST['cname']; print "Your connections is: [$c] <br/>"; $query = "SELECT custid, first from customer"; $stmt = OCIParse($c, $query); OCIExecute($stmt); while(OCIFetchInto($stmt, $row, OCI_ASSOC)) { // ename and job must be in capital letters echo $row['CUSTID']. " - " .$row['FIRST']. "<br>"; } OCILogoff($c); ?> As you can see the variables txtun + txtpw are already declared in my html form. What must i do to change it so that when they click on the table link in my handler1.php file it displays the contents of my customer table given table.php file?? Please help if u can. SQL> desc customer; Name Null? Type ------------------------------- -------- ---- CUSTID NOT NULL NUMBER(5) LAST NOT NULL VARCHAR2(30) FIRST VARCHAR2(30) MID_INITIAL CHAR(1) CADD VARCHAR2(30) TOWN VARCHAR2(30) CITY VARCHAR2(30) POSTCODE VARCHAR2(10) DPHONE VARCHAR2(10) EPHONE VARCHAR2(10) Here is the program logic to help: connect.html(enter my username + pssword) -> handler1.php(if correct connect do my db) -> table.php(display custid + name in Customer table). Link to comment https://forums.phpfreaks.com/topic/43009-undefined-index-problem/ Share on other sites More sharing options...
christophe Posted March 16, 2007 Share Posted March 16, 2007 have you defined primary key in sql Link to comment https://forums.phpfreaks.com/topic/43009-undefined-index-problem/#findComment-208881 Share on other sites More sharing options...
nvidia Posted March 16, 2007 Author Share Posted March 16, 2007 Yes, custid is the primary key in my customer table. Link to comment https://forums.phpfreaks.com/topic/43009-undefined-index-problem/#findComment-208884 Share on other sites More sharing options...
per1os Posted March 16, 2007 Share Posted March 16, 2007 echo $row['custid']. " - " .$row['first']. "<br>"; The indexes are case-sensitive. If in your select query you state "SELECT bOb from table..." the index would HAVE to be bOb. Link to comment https://forums.phpfreaks.com/topic/43009-undefined-index-problem/#findComment-208900 Share on other sites More sharing options...
nvidia Posted March 16, 2007 Author Share Posted March 16, 2007 Hi i have changed the select statement to upper case i.e CUSTID + FIRST but i'm still getting the same error? Do i need to incorporate a session for this? If so, how would that work? Link to comment https://forums.phpfreaks.com/topic/43009-undefined-index-problem/#findComment-208904 Share on other sites More sharing options...
per1os Posted March 16, 2007 Share Posted March 16, 2007 http://us3.php.net/manual/en/function.oci-fetch-array.php The ocifetchinto is depreciated. Try that function instead. Link to comment https://forums.phpfreaks.com/topic/43009-undefined-index-problem/#findComment-208954 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.