I am developing my first simple site using PHP. Now I work on the admin page, and I want him to add, delete users and edit personal information about existing users. I added and removed. Now I want to develop editing users. First of all, I want him to select a user from the list, then automatically extract information about the user after selecting from the list, and then edit his information. So how can I do this?
My code is:
<?php ob_start(); $host="localhost"; <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script language="javascript"> function reload(form){ var val=form.username.options[form.username.options.selectedIndex].value; self.location='editUser2.php?username=' + val ; } </script> </head> <body> <div id="content_main" class="admin_student_height"> <form method="get"> <h3>Choose A User</h3> <br /> select name="username" onchange="reload(this.form)"> <option> <?php if(isset($_GET['username'])) echo "{$_GET['username']}"; else echo "Select one"; ?> </option> <?php if(isset($_GET['username'])){ $exceptcc = $_GET['username']; $sql = "SELECT username FROM user WHERE user.username NOT IN ('$exceptcc')"; } else $sql = "SELECT username FROM user"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ echo "<option value={$row['username']}>{$row['username']}</option>"; } ?> </select><br /><br /> <h3>User Information</h3> <br /> <?php $thecc = $_GET['username']; $sql = "SELECT Firstname FROM user WHERE Username=$thecc"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ echo "{$row['Firstname']}>{$row['Firstname']}}"; } ?> <br /><br /> </form> <br /> </div> </div> </body>
source share