I am having a problem using php to submitting a form. For some reason PHP won't handle the form variables... I am using PHP Version 4.2.2 on a redhat 8 system.. I used this code from a book called PHP and MySQL Web Development.
<?php /* the main failure in this site is that I can't seem to submit the form properly. the variables wont' work */ session_start(); //$userid = "ant"; //$password = "ant"; /* wanted to see if this form actually received the form variables */ echo "$userid"; echo "$password"; if ($id && $password) { // if the user has just tried to log in $db_conn = mysql_connect("localhost", "root", ""); mysql_select_db("test", $db_conn); $query = "select * from auth " ."where userid='$userid' " ." and password=password('$password')"; $result = mysql_query($query, $db_conn); if (($num_rows = mysql_num_rows($result)) > 0 ) { echo "$num_rows"; // if they are in the database register the user id $valid_user = $userid; session_register("valid_user"); } echo "$userid"; echo "$password"; } else { echo "this is not working"; } ?> <html> <body> <h1>Home page</h1> <?php if (session_is_registered("valid_user")) { echo "You are logged in as: $valid_user <br>"; echo "<a href=\"logout.php\">Log out</a><br>"; } else { // This part fails also if (isset($userid)) { // if they've tried and failed to log in echo "Could not log you in"; } else { // they have not tried to log in yet or have logged out echo "You are not logged in.<br>"; } // provide form to log in echo "<form method=get action=\"authmain.php\">"; echo "<table>"; echo "<tr><td>Userid:</td>"; echo "<td><input type=text name=userid></td></tr>"; echo "<tr><td>Password:</td>"; echo "<td><input type=password name=password></td></tr>"; echo "<tr><td colspan=2 align=center>"; echo "<input type=submit value=\"Login\"></td></tr>"; echo "</table></form>"; } ?> <br> <a href="members_only.php">Members section</a> </body> </html> -- ____ _ _ ___ ____ _ _ _ ____ ____ ____ _ ____ _ _ ____ _ _ |__| |\ | | | | | |\ | |___ [__ | | | | | |\/| | | |\ | | | | \| | |__| | | \| |___ ___] |__| |___ |__| | | |__| | \| -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php