Sunday, 15 May 2011

PHP Form submit on condition -


I have a basic form, I only want to execute it when user input matches a set Can I create user so that user can supply "username" and password "password 1" if the page can go to the page?

input type = 'text' name = 'username' value = 'admin' & gt; & lt; Br> Password: & lt; br & gt; method = 'post' action = 'addbooks.php' & lt; input type = 'text' name = 'password' value = '' & gt; & lt; br & Gt; & lt; br & gt; Input type = 'Submit' name = 'sbmt' id = 'sbmt' value = 'user_value' Class = 'user_class' onSubmit =' submit submit; /> & Lt; / form & gt; "; Submit the function () (if ($ _ POST ['username'] == 'admin') & amp; amp; ($ _ POST ['password'] == 'password1') {true;} Else { Warning ("Please check user name and password") return false;}}

Edit:

To clear the problem.

I am trying to create a form with a username and password input. When the user clicks on this form, then he currently has the user addboo Ks.php.I want to make this conditional so that users can only access addbooks.php page, if user name = "admin" and provide password then provide "password 1". I currently click on the button Try to execute the submission function and submit the submit function if the user name and password match the administrator and password 1. If they do so, then you can add it to addbooks.php

You can try it (note headers ("Location: addBooks.php" ) The part should be at the top of your code, before any HTML output is done):

  if (isset ($ _ POST ["user name"]) and continue ($ { _POST ["password"]) {if (($ _POST ["user name"] == "admin") and ($ _POST ["password"] == "password 1") {header ("Location: AdBook Php "); Go out; } Else {echo "Please check the username and password 
"}}} // Admin login echo & lt; Form method = "post" action = "'. $ _ SERVER [' PHP_SELF ']. & Gt; Username:
input type =" text "name =" username "value = "Admin">
Password:
Input Type = "Text" name = "password" value = "" & gt; & lt; br />
Input Type = "submit" name = "sbmt" id = "sbmt" value = "submit" class = "user_class" />

No comments:

Post a Comment