SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2000
    Location
    Location:
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Greetings everyone .

    I seem to be experiencing a problem with the include function on my script.

    Here is my script:


    <FORM ACTION="login25.php?do=authenticate" METHOD="post">
    <!-- Create the form feilds in a pretty table -->
    <table border=0>

    <tr>
    <td><strong>User_name</strong></td>
    <td><input type="text" name="user_name" size="10" maxlength="10"></td>
    </tr>

    <tr>
    <td><strong>Password</strong></td>
    <td><input type="password" name="password" size="10" maxlength="10"></td>
    </tr>


    <tr>
    <td colspan="2" align="center">
    <input type="submit" value="Validate Me">
    </td>
    </tr>
    </table>
    </form>

    <!-- login2.php -->
    <!-- This file begins like any normal HTML file -->

    <HTML>
    <HEAD>
    <TITLE>My Login Form</TITLE>
    </HEAD>

    <! --PHP code starts here!! -->

    <?

    switch ($do) {

    case "authenticate":

    $connection = mysql_connect("localhost", "Koncise", "*******")
    or die ("Couldn't connect to server.");

    $db = mysql_select_db("Koncise", $connection)
    or die ("Couldn't select database.");

    $sql = "SELECT ID
    FROM Groups
    WHERE user_name='$user_name' and password='$password'";

    $result = mysql_query($sql)
    or die("Couldn't execute query.");

    $num = mysql_numrows($result);

    if ($num == 1) {

    echo "<P>You are a valid user!<br>";
    echo "Your username is $user_name<br>";
    echo "Your password is $password</p>";

    } else if ($num == 0) {

    unset($do);
    echo "You are not authorized! Please try again.</p>";


    }

    break;

    default:

    include("login_form.inc");

    }

    ?>

    <! --The PHP code stops here, we are now back in HTML -->

    </BODY>
    </HTML>

    When I attempt to proccess the form, I am presented with the following error message:

    Warning: Unable to access login_form.inc in /usr/home/sites/Koncise/web/login_form.html on line 75

    Warning: Failed opening 'login_form.inc' for inclusion (include_path='') in /usr/home/sites/Koncise/web/login_form.html on line 75

    The error points to line 75, which is the include function
    ( include("login_form.inc"); ), however I don't see whats wrong with it.

    I would be very greatful if anyone could point out what I have done wrong.

    Thank you very much...!

    Koncise.

  2. #2
    SitePoint Zealot HotDog's Avatar
    Join Date
    May 2000
    Location
    Salt Lake City, UT
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is your login_form.inc in the same directory as your form.php file? If not you can either put the two in the same directory, or include the path to the login_form.inc in your form.php file.
    Joe Eliason
    Just a dog learnin' PHP from cat.

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2000
    Location
    Location:
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi HotDaog.

    My login_form.inc is in the same folder as my form.php. file - yes.

    I have a file called login_form.html which calls on the script above, which then calls on the script included within it (login25.php).

    Does that make sense?

    What is bugging me is that when I run this exact same script via my local sever it works fine, however when I run the script via my webhost/webserver - it refuses to work!

    Thanx for helping,

    (an exasperated) Koncise.

  4. #4
    SitePoint Zealot HotDog's Avatar
    Join Date
    May 2000
    Location
    Salt Lake City, UT
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure if I follow you exactly but this is what I suggest from how I interpret what you are saying.

    Try changing your login_form.html file to login_form.php. The problem is the server needs to know which files to send through the php server and which ones it can ignore. The server knows this by the file extension (.php, .phtml, .php3, etc.). Your local server may be setup up (I don't know) to also send all html files to the php server where your remote host only sends files with .php type extensions. If the file doesn't go through the php server, it doesn't know what to do with the include. My suggestion would be to give this a try and see what happens.

    If I'm totally missing the problem let me know and I'll try again.
    Joe Eliason
    Just a dog learnin' PHP from cat.

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2000
    Location
    Location:
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanx HotDog....I'll try that out.

    Koncise!

  6. #6
    SitePoint Enthusiast
    Join Date
    Oct 2000
    Location
    Location:
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok I changed the login_form.html file to login_form.php.
    How ever I'm still presented with the same error message:

    Warning: Unable to access login_form.inc in /usr/home/sites/Koncise/web/login_form.php on line 75

    Warning: Failed opening 'login_form.inc' for inclusion (include_path='') in /usr/home/sites/Koncise/web/login_form.php on line 75

    Which again points to the include function:

    include("login_form.inc");

    Perhaps you are right HotDog, it seems as though this particular the webhost server cannot execute (include) functions.....although there is a possibility that the problem may be due to something else.

    The webhost I'm using is Datablocks.net. I'm using them just to test how the scripts would work over the web. They are very unrelaible, now I can't access my phpmyadmin area.

    I plan on using Hostrocket - I hear that they are reliable and supportive, hopefully their server will be able to process the include function within this script.

    Thanx,

    Koncise.

  7. #7
    SitePoint Zealot HotDog's Avatar
    Join Date
    May 2000
    Location
    Salt Lake City, UT
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should be able to include other files no matter what PHP server you are running on. I guess I'm not quite understanding how all your files are related to eachother and how each one is being used. You have already done this, but explain agian to me which file is the main page (the one with the form) and which one is the include page and any other files involved with an explaination of what it's relationship is with the other files. It is probibly something in the coding. If I don't know the answer, someone else should be able to help.
    Joe Eliason
    Just a dog learnin' PHP from cat.

  8. #8
    SitePoint Enthusiast
    Join Date
    Oct 2000
    Location
    Location:
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok...one sec:

  9. #9
    SitePoint Enthusiast
    Join Date
    Oct 2000
    Location
    Location:
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, its like this:

    The main file is this one below, this file contains a simple two-feild form which asks the user to enter their username and password. This form is called login_form.html

    Here is it:

    <!-- Configure the form -->

    <FORM ACTION="login25.php?do=authenticate" METHOD="post">
    <!-- Create the form feilds in a simple two-field table -->
    <table border=0>

    <tr>
    <td><strong>User_name</strong></td>
    <td><input type="text" name="user_name" size="10" maxlength="10"></td>
    </tr>

    <tr>
    <td><strong>Password</strong></td>
    <td><input type="password" name="password" size="10" maxlength="10"></td>
    </tr>


    <tr>
    <td colspan="2" align="center">
    <input type="submit" value="Validate Me">
    </td>
    </tr>
    </table>
    </form>

    <!-- login2.php -->
    <!-- This file begins like any normal HTML file -->

    <HTML>
    <HEAD>
    <TITLE>My Login Form</TITLE>
    </HEAD>

    <! --PHP code starts here!! -->

    <?

    switch ($do) {

    case "authenticate":

    $connection = mysql_connect("localhost", "Koncise", "***")
    or die ("Couldn't connect to server.");

    $db = mysql_select_db("Koncise", $connection)
    or die ("Couldn't select database.");

    $sql = "SELECT ID
    FROM Groups
    WHERE user_name='$user_name' and password='$password'";

    $result = mysql_query($sql)
    or die("Couldn't execute query.");

    $num = mysql_numrows($result);

    if ($num == 1) {

    echo "<P>You are a valid user!<br>";
    echo "Your username is $user_name<br>";
    echo "Your password is $password</p>";

    } else if ($num == 0) {

    unset($do);
    echo "You are not authorized! Please try again.</p>";


    }

    break;

    default:

    include("login_form.inc");

    }

    ?>

    <! --The PHP code stops here, we are now back in HTML -->

    </BODY>
    </HTML>


    As you can see, the form action points to the login25.php file which is also within the same folder as this login_form.html file.

    As mentioned, this exact same script, works fine on my local server, however when running this cript from my www dir the error always points to line 75, which is the include function:

    include("login_form.inc");


    I'm trully baffled as to why this is,

    thats the deal, thanx!


    Koncise

  10. #10
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So this happens only on a remote server, like the one of your host? Have you tried supplying the whole unix path to the file

    like:

    include("/usr/home/sites/Koncise/web/login_form.inc");

    or whatever the path to the file is?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  11. #11
    SitePoint Enthusiast
    Join Date
    Oct 2000
    Location
    Location:
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahh, no I have'nt tried that Freddy..thanx.

    I will give it ago, I'll be right back.

    Koncise!

  12. #12
    SitePoint Enthusiast
    Join Date
    Oct 2000
    Location
    Location:
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey!

    Problem solved!!!

    I deleted the include function altogether and the form worked without fault, brilliant!!!

    Boy, that was an experience....

    Thanx for taking the time to help me out freddydoesphp and HotDog.



    Koncise.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •