Jump to content

Undefined index problem????


nvidia

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.