cubx Posted December 8, 2006 Share Posted December 8, 2006 I am making a long php script that will have 5 forms on it. What it is supposed to do is display the first form, asking username and such, on submit it checks for duplicates, then goes to the second form, gets password, on submit it checks for duplicates, and so forth.When I had 2 pages, it was working fine, but now that I am up to 4, I load the script and it shows all 4 on one page, and it is not waiting until I click submit. Here is a sample of the code:if (!isset($_POST['Submit'])) page_one();else global $link; if (connect_to_db()) { if (!empty($_POST['username']) && !empty($_POST['password'])) if(!checklength($_POST['password'], 5, 15)) echo "Password must be between 5-15 characters<br>"; else // Query the database $sql = "SELECT username FROM accounts WHERE username = '{$_POST['username']}'"; // Check if we got a result returned $result = mysql_query($sql, $link); if (isset($_POST['Submit'])) { if (!$result) { echo "Couldn't execute: $sql<br><br>\n" . mysql_error(); } // result else { // begin check for username // Does the user exist, how many rows were retrurned if (mysql_num_rows($result) > 0) { echo "Username already in use\n"; } else $insert = "INSERT INTO accounts (username, password) VALUES ('{$_POST['username']}', '{$_POST['password']}')"; if (!mysql_query($insert)) die(mysql_error());} // end check username} // end connect to db if (!isset($_POST['submit'])) page_two(); if (!empty($_POST['phrase'])) { if (!checklength($_POST['phrase'], 5, 15)) echo "Phrase must be between 5-15 characters"; I'm not getting any errors, but it is not waiting for submit, it just displays all 4 pages at once. All I really want this to do is display page_one(), wait for input, test it against mysql, then move on to page_two(), and so on.Any suggestions as to what I'm missing, or a better way to do this? Link to comment https://forums.phpfreaks.com/topic/29940-multiple-forms-on-one-script/ Share on other sites More sharing options...
kenrbnsn Posted December 8, 2006 Share Posted December 8, 2006 You probably want to check the value of the submit button as well as if it is set. Make sure each submit button has a unique value.If you post the script that generates the form, we can help you more.Ken Link to comment https://forums.phpfreaks.com/topic/29940-multiple-forms-on-one-script/#findComment-137561 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.