Schlo_50 Posted December 19, 2007 Share Posted December 19, 2007 I working on a login system in which a user types a username and password, and then selects a radio button which matches their account type. So if the user attempts a login using department credentials and selects the 'master account' radio button then they shouldn't be able to login, however if the user attempts a login using department credentials and clicks the radio button to confirm they are a department then they will successfully login. (Assuming they have entered the correct details.) Login Form: <?php $username = isset($_POST['username']) ? $_POST['username'] : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; $selected_radio = $_POST['master']; $selected_radio2 = $_POST['department']; ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="loginform"> <p class="text" align="center"><span class="main"><img src="images/point.png" width="11" height="8" />Username:</span> <input class="text" name="username" type="text" /> </p> <p class="text" align="center"><span class="main"><img src="images/point.png" width="11" height="8" />Password:</span> <input class="text" name="password" type="password" /> </p> <p class="text" align="center"> <input type = 'Radio' Name ='client' value= 'master'>Master Site <input type = 'Radio' Name ='client' value= 'department'>Sub Site or Department</p> <p class="text" align="center"> <input class="text" type="submit" name="submitBtn" value="Login" /> </p> </form> Processing Code: if ($selected_radio = $_POST['master']){ $pfile = fopen("users.txt","r"); rewind($pfile); while (!feof($pfile)) { $line = fgets($pfile); $tmp = explode('|', $line); if ($tmp[0] == $user) { // User exists, check password if (trim($tmp[1]) == trim(md5($pass))){ $validUser= true; $_SESSION['userName'] = $user; } break; } } fclose($pfile); } else { $pfile = fopen("departments.txt","r"); rewind($pfile); while (!feof($pfile)) { $line = fgets($pfile); $tmp = explode('|', $line); if ($tmp[0] == $user) { // User exists, check password if (trim($tmp[1]) == trim(md5($pass))){ $validUser= true; $_SESSION['userName'] = $user; } break; } } fclose($pfile); } What i want the processing code to try and do is say, "if the use selects to login as a master account search users.txt for a match, else, search departments.txt for a match". Please could i get some help, if you need any questions answered please ask. Thanks Link to comment https://forums.phpfreaks.com/topic/82305-radio-button-help/ Share on other sites More sharing options...
papaface Posted December 19, 2007 Share Posted December 19, 2007 Use a mysql database instead of a flat file database. So much easier. Link to comment https://forums.phpfreaks.com/topic/82305-radio-button-help/#findComment-418356 Share on other sites More sharing options...
Schlo_50 Posted December 19, 2007 Author Share Posted December 19, 2007 I know it is, i apreciate the response but that wasn't the the answer to the question i was asking.. Can anybody help my php problem above? Thanks Link to comment https://forums.phpfreaks.com/topic/82305-radio-button-help/#findComment-418412 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.