Results 1 to 9 of 9

Thread: 2 Quick Qs

  1. #1
    Join Date
    Feb 2004
    Location
    Irving, TX (Dallas, Fort Worth)
    Posts
    379

    Unanswered: 2 Quick Qs

    1. I need to load Apache and PHP on the local desktop. I can't always be online. Links and resources please.

    2. I wrote a PHP script that logs to an FTP site but I need to run verification of the login and then enable download and upload when it is good. Samples please.

    Thanks!

  2. #2
    Join Date
    Oct 2003
    Location
    Slovakia
    Posts
    482

    Re: 2 Quick Qs

    Originally posted by dbsupport4me
    1. I need to load Apache and PHP on the local desktop. I can't always be online. Links and resources please.

    2. I wrote a PHP script that logs to an FTP site but I need to run verification of the login and then enable download and upload when it is good. Samples please.

    Thanks!
    Here are the relevant links. Here you can find everything including docs and instalation packages.
    www.php.net
    www.apache.org

  3. #3
    Join Date
    Feb 2004
    Location
    Irving, TX (Dallas, Fort Worth)
    Posts
    379

    Re: 2 Quick Qs

    Okay that answer Q one, what about number 2?

    Do I need to submit an example?


    Originally posted by ika
    Here are the relevant links. Here you can find everything including docs and instalation packages.
    www.php.net
    www.apache.org

  4. #4
    Join Date
    Feb 2004
    Location
    Irving, TX (Dallas, Fort Worth)
    Posts
    379

    Re: 2 Quick Qs

    Here is my source for this login script. You will have to build your own MySQL connect block:

    ///***** Strart Script *****///

    <?php
    include("connectdb.php");

    $beg_block = "
    $msg
    <table width=350 border=0 cellpadding=3>
    <form method=post action=\"$PHP_SELF\" name=log>
    <tr>
    <td colspan=2 align=center>
    <font size=\"+2\" color=\"#0055aa\">
    <b>Logon to FTP Server!</b></td>
    </font>
    </tr>
    <tr>
    <td>Client:</td>
    <td><select size=\"1\" name=\"client\">
    <option selected>Select Your Comp Name</option>
    ";

    $cent_block = "";

    $end_block = "
    </select></td>
    </tr>
    <tr>
    <td>Username:</td>
    <td><input type=text name=username size=20></td>
    </tr>
    <tr>
    <td>Password:</td>
    <td><input type=password name=password size=20></td>
    </tr>
    <tr>
    <td>Server:</td>
    <td><tt>ftp://</tt><input type=text name=server size=14></td>
    </tr>
    <tr>
    <td colspan=2 align=center>
    <input type=\"checkbox\" name=\"cookie\" value=\"ON\">&nbsp;&nbsp;Save FTP Values
    <input type=\"checkbox\" name=\"auto\" value=\"ON\">&nbsp;&nbsp;Automatically Login
    <input type=\"hidden\" name=\"op\" value=\"ds\">
    </td>
    </tr>
    <tr>
    <td colspan=2 align=center>
    <input type=submit name=login value=login></td>
    </tr>
    </form>
    </table>
    <hr>
    ";

    $logged_block = "
    <table width=350 border=0 cellpadding=3>
    <form method=post action=\"$PHP_SELF\" name=log>
    <tr>
    <td colspan=2 align=center><font size=\"+2\" color=\"#0055aa\"><b>Logged on as:</b></font></td>
    </tr>
    <tr><td colspan=2>&nbsp;</td></tr>
    <tr><td colspan=2>$username</td></tr>
    <tr><td colspan=2><input type=\"hidden\" name=\"op\" value=\"ds\"></td></tr>
    </form>
    </table>
    <hr>
    ";

    $mid_block = "";

    $msg = "";

    $sql = "SELECT Con_ID, Con_Comp FROM Contact";
    $result = mysql_query($sql);
    if (!$result) {
    echo "Could not successfully run query ($sql) from DB: " . mysql_error();
    exit;
    }
    if (mysql_num_rows($result) == 0) {
    echo "No rows found, nothing to print so am exiting";
    exit;
    }

    while ($row = mysql_fetch_object($result)) {
    $mid_block .= "<option VALUE=$row->Con_ID>$row->Con_Comp</option>";
    }

    $unlog_block = $beg_block . $mid_block . $end_block;

    mysql_free_result($result);

    if ($op == "ds") {
    if (($username != "admin") || ($password != "abc123")) {
    $msg = "
    <p><font color=\"#FF0000\"><b>Bad Login - Try Again</b></font>
    ";
    $show_form = "yes";
    } else {
    session_register('valid');
    $valid = "yes";
    $show_menu = "yes";
    }
    } else {
    if ($valid == "yes") {
    $show_menu = "yes";
    } else {
    $show_form = "yes";
    }
    }

    if ($show_form == "yes") {
    $display_block = $unlog_block;
    } else if ($show_menu == "yes") {
    $display_block = $logged_block;
    }

    $session_vars = "
    Message: $msg
    <br>Log: $log
    ";
    ?>

    <html>
    <head>
    <title>FTP Login Test Page</title>
    </head>

    <body>
    <center>
    <font size="+3" color="#0055aa">
    <b>FTP Login Test Page</b>
    </font>
    <hr>

    <? echo $display_block; ?>
    <? echo $session_vars; ?>
    <hr>
    </center>
    </body>
    </html>

    ///***** End Script *****///


    Originally posted by dbsupport4me
    Okay that answer Q one, what about number 2?

    Do I need to submit an example?

  5. #5
    Join Date
    Oct 2003
    Location
    Slovakia
    Posts
    482

    Re: 2 Quick Qs

    Originally posted by dbsupport4me
    Here is my source for this login script. You will have to build your own MySQL connect block:

    ///***** Strart Script *****///

    <?php
    include("connectdb.php");

    $beg_block = "
    $msg
    <table width=350 border=0 cellpadding=3>
    <form method=post action=\"$PHP_SELF\" name=log>
    <tr>
    <td colspan=2 align=center>
    <font size=\"+2\" color=\"#0055aa\">
    <b>Logon to FTP Server!</b></td>
    </font>
    </tr>
    <tr>
    <td>Client:</td>
    <td><select size=\"1\" name=\"client\">
    <option selected>Select Your Comp Name</option>
    ";

    $cent_block = "";

    $end_block = "
    </select></td>
    </tr>
    <tr>
    <td>Username:</td>
    <td><input type=text name=username size=20></td>
    </tr>
    <tr>
    <td>Password:</td>
    <td><input type=password name=password size=20></td>
    </tr>
    <tr>
    <td>Server:</td>
    <td><tt>ftp://</tt><input type=text name=server size=14></td>
    </tr>
    <tr>
    <td colspan=2 align=center>
    <input type=\"checkbox\" name=\"cookie\" value=\"ON\">&nbsp;&nbsp;Save FTP Values
    <input type=\"checkbox\" name=\"auto\" value=\"ON\">&nbsp;&nbsp;Automatically Login
    <input type=\"hidden\" name=\"op\" value=\"ds\">
    </td>
    </tr>
    <tr>
    <td colspan=2 align=center>
    <input type=submit name=login value=login></td>
    </tr>
    </form>
    </table>
    <hr>
    ";

    $logged_block = "
    <table width=350 border=0 cellpadding=3>
    <form method=post action=\"$PHP_SELF\" name=log>
    <tr>
    <td colspan=2 align=center><font size=\"+2\" color=\"#0055aa\"><b>Logged on as:</b></font></td>
    </tr>
    <tr><td colspan=2>&nbsp;</td></tr>
    <tr><td colspan=2>$username</td></tr>
    <tr><td colspan=2><input type=\"hidden\" name=\"op\" value=\"ds\"></td></tr>
    </form>
    </table>
    <hr>
    ";

    $mid_block = "";

    $msg = "";

    $sql = "SELECT Con_ID, Con_Comp FROM Contact";
    $result = mysql_query($sql);
    if (!$result) {
    echo "Could not successfully run query ($sql) from DB: " . mysql_error();
    exit;
    }
    if (mysql_num_rows($result) == 0) {
    echo "No rows found, nothing to print so am exiting";
    exit;
    }

    while ($row = mysql_fetch_object($result)) {
    $mid_block .= "<option VALUE=$row->Con_ID>$row->Con_Comp</option>";
    }

    $unlog_block = $beg_block . $mid_block . $end_block;

    mysql_free_result($result);

    if ($op == "ds") {
    if (($username != "admin") || ($password != "abc123")) {
    $msg = "
    <p><font color=\"#FF0000\"><b>Bad Login - Try Again</b></font>
    ";
    $show_form = "yes";
    } else {
    session_register('valid');
    $valid = "yes";
    $show_menu = "yes";
    }
    } else {
    if ($valid == "yes") {
    $show_menu = "yes";
    } else {
    $show_form = "yes";
    }
    }

    if ($show_form == "yes") {
    $display_block = $unlog_block;
    } else if ($show_menu == "yes") {
    $display_block = $logged_block;
    }

    $session_vars = "
    Message: $msg
    <br>Log: $log
    ";
    ?>

    <html>
    <head>
    <title>FTP Login Test Page</title>
    </head>

    <body>
    <center>
    <font size="+3" color="#0055aa">
    <b>FTP Login Test Page</b>
    </font>
    <hr>

    <? echo $display_block; ?>
    <? echo $session_vars; ?>
    <hr>
    </center>
    </body>
    </html>

    ///***** End Script *****///
    Read The Friendly Manual: http://www.php.net/manual/en/ref.ftp.php

  6. #6
    Join Date
    Feb 2004
    Location
    Irving, TX (Dallas, Fort Worth)
    Posts
    379

    Futher Support

    I looked this code over and think I have it, but I need to take action when the first HTML Input Field is changed. I have been looking through both the PHP and HTML sites to try to understand this.

    So far the answer hasn't jumped out a grabbed me yet.

    Basically, to test, I put 2 entries in my DB so I would see two selections in the first input <select> field. What I am trying to do is then, based on the selection, query the second DB table containing FTP login information, with the select values, so I can find the FTP login information.

    I am also interested in securing the transfer of this data, so how do I accomplish all this?

  7. #7
    Join Date
    Feb 2004
    Location
    Irving, TX (Dallas, Fort Worth)
    Posts
    379

    Re: 2 Quick Qs

    Originally posted by ika
    Read The Friendly Manual: http://www.php.net/manual/en/ref.ftp.php
    I added an include as follows:

    include("proc_log.php");

    at the top and the proc follows:

    ********* proc ==> proc_log.php **********

    <?php
    $server = "ftp.myserver.net";
    // set up basic connection
    $conn_id = ftp_connect($server);

    // login with username and password
    if (($username<>"") AND ($password<>"")) {
    $login_result = ftp_login($conn_id, $username, $password);
    // check connection
    if ((!$conn_id) || (!$login_result)) {
    echo "FTP connection has failed!";
    echo "Attempted to connect to $ftp_server for user $ftp_user_name";
    exit;
    } else {
    // echo "Connected to $server, for user $username";
    }
    }
    ?>

    ********** End Proc **********

    What I haven't mastered with this is transfer of variables and rewrite of screen from the original script, based on results in the proc. How do I do that?

  8. #8
    Join Date
    Feb 2004
    Location
    Irving, TX (Dallas, Fort Worth)
    Posts
    379

    Help Please!!

    Anyone Can you help??

  9. #9
    Join Date
    Feb 2004
    Location
    Irving, TX (Dallas, Fort Worth)
    Posts
    379

    Can I get some help?

    Still have no help on my script issue

Posting Permissions

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