How to refresh page on form submission?

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

Was this solution helpful to you?

Just Added Q & A:

Find solution

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.