Need help with form action+php?
-
for a login page after the submission i need to check the database and for the invalid users display a msg on the same page and at the same time for the valid users open the next page. how can i do this in code. the following shows my coding for the form <FORM action=next.php method="post"> the php coding for the submission <?php if ( isset( $_POST['submit_x'] ) ) { $user_name=$_POST['user_name']; $psword=$_POST['psword']; $query = "SELECT * from user WHERE user_name=rtrim('$user_name') "; $result = mysql_query($query); if (!mysql_fetch_row($result)) { echo 'error user' ; } else { $query1 = "SELECT * from user WHERE psword=rtrim('$psword') AND user_name=rtrim('$user_name') "; $result1 = mysql_query($query1); if (!mysql_fetch_row($result1)) { echo 'error password' ; } else{ ########################### }} } ?> for the place noted by ################## i need to add the coding to shift to the other php page. how can i do that plz help
-
Answer:
<html> <body> <?php if ($_POST['user_name'] && $_POST['psword'] ) { $user_name=$_POST['user_name']; $psword=$_POST['psword']; $query = "SELECT * from user WHERE user_name= '" . rtrim($user_name) . "' and psword = '" . rtrim($psword) . "'"; $result = mysql_query($query); if (!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } else { echo "Welcome " . $user_name; } } #end if else { #if user did not submit ?> <FORM action="#" method="post"> <input type = "text" name ="user_name" value = ""> <input type = "password" name ="psword" value = ""> <input type = "submit" value = "login"> </FORM > <?php } ?> </body</html>
th at Yahoo! Answers Visit the source
Related Q & A:
- I need help on what I need to buy or do.Best solution by Yahoo! Answers
- I need help with some horse questions, can you help me.Best solution by Yahoo! Answers
- I did something really bad and now i need help please help me.Best solution by Yahoo! Answers
- What is an easy code for a form in PHP?Best solution by Stack Overflow
- What sort of opportunities are there to help people in Africa or places where people need help?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.