Dr. Shim wrote:

>I've tried repediately to have a PHP script validate a form when the form is
>submitted. I'm quite new to PHP, and I'd really appreciate the help anybody
>could give me. I've been stuck on this problem far to long.
>
>I have a form (here's the code):
>
><form method="post" action="<?php $PHP_SELF; ?>">
>  Username:
>  <input type="text" name="username" maxlength="255" value="<?
>$HTTP_POST_VARS['username']; ?>">
>
The shortcut is <?php =$blah?>, not <?php $blah?>

>  <br>
>  Password:
>  <input type="text" name="password" maxlength="8" value="<?
>$HTTP_POST_VARS['password']; ?>">
>  <br>
>  <input type="submit" name="login" value="Log In"
>onclick="document.refresh()">
>
document.submit() should do it, refresh() will just reload the page.

>  <br>
>  <br>
></form>
>
>And right underneath the form code, I have my PHP script:
>
><?php
> if (isset($login)) {
>  insert();
> }
>
> function insert() {
>  $db = odbc_connect('mydatabase', 'myusername', 'mypassword');
>
>  if(!$db) {
>   echo "An error has occured. Please <a
>href=\"mailto:[EMAIL PROTECTED]\";>e-mail</a> the text below to
>me.<br><br>~~~~~~~<br>$PHP_ERROR<br>$db<br>~~~~~~~";
>  }
>
>  $SQLQuery = "SELECT fldID FROM tblUsers WHERE fldUsername = '$username'
>AND fldPassword = '$password'";
>  $cursor = odbc_exec($db, $SQLQuery);
>
>  if (!$cursor) {
>   echo "An error has occured. Please <a
>href=\"mailto:[EMAIL PROTECTED]\";>e-mail</a> the text below to
>me.<br><br>~~~~~~~~<br>" . odbc_errormsg($db) . "<br>~~~~~~~";
>  }
> }
>   ?>
>
>What I'm trying to achieve here is that when the user fills out the form,
>presses the "Log In" button, the script underneath validates and inserts the
>data into a database.  Now, I click on the "Log In" button, nothing happens.
>
>Could anybody please help me with this? I would really, really appreciat any
>help.
>
>
>





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to