Data submit form with password protection


I’ve put together a page where I can easily submit data into an sql database. I have also password protected the page. The problem is that I now have two forms on one page and I’m unsure what the best method would be to get this to work. The login works fine, as does the data submit form, but when used together, the data submit for doesn’t submit and simply returns me to the login view.

Can anyone please clear up what it is I’m doing wrong or suggest an alternative - perhaps a password on the submit data form ?

Thank you in advance


<?php require_once('/home/cpanel_login/php/db_all.php'); //password file above public_html if (isset($_POST["pwd"]) && ($_POST["pwd"]=="$pwd")) { $hostname = "localhost"; $db_user = "$username6"; $db_password = "$password"; $database = "$database6"; $db_table = "$table6"; $db = mysql_connect($hostname, $db_user, $db_password); mysql_select_db($database) or die( "Unable to select database"); if (isset($_REQUEST['Submit'])) { $sql = "INSERT INTO $db_table(name,IP) values ('".($_REQUEST['name'])."','".($_REQUEST['ip'])."')"; if($result = mysql_query($sql ,$db)) { echo 'Data Submitted'; } else { echo "ERROR: ".mysql_error(); } } else { echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; } } else { if (isset($_POST['pwd']) || $pwd == "") { print "

Incorrect Password

";} print "

Enter password
"; print "

"; } ?>[/php]


You don’t have a form on the bottom one. no form = no action to be taken.


Hi, thank you for the quick reply.
I’m not with you sorry, the bottom section provides the login form:

[php]print “<form name=“pass1” method=“post”><p align=“left”>Enter password


Yes i didn’t see it, sorry. but, on that same form, your submit button doesn’t have a name [<input value=“Login” type=“submit”>]


OK thanks, have added a submit name but I’m still being returned to the login page after submitting data via the sql form I’m afraid.