I want an administrator page where I can browse and edit my members. Not all fields will be possible to change (like the id field i use as a key).
I tried to make a page where i read the user database and print the values into input forms and then add a submit button at the end of each line.
When pressing the submit button the idea is to transfer the values to a page called admin.php that will get the submitted values and update the db.
I got it working so far so it fills out the names and info inside the input fields but when i press the submit button I cannot retreive the values inside admin.php
The code from the sending page:
Code: Select all
$stmt = $mysqli->prepare("SELECT id, username, email, userlevel, useravatar, userrating FROM users ");
$stmt->execute();
$stmt->bind_result($u_id, $u_username, $u_email, $u_userlevel, $u_useravatar, $u_userrating);
$stmt->store_result();
echo '...ID..........NAMN...........................EMAIL.....................................LEVEL.........AVATAR..............Rating <br>';
while($row=$stmt->fetch()){
?><form id=<?php echo $u_id; ?> name="form1" method="post" action="admin.php"><?php //EJ KLAR
echo $u_id;
?><input name ="id" type="hidden" id="u_id" value=<?echo $u_id?>><?php
?><td><input name="name" type="text" id="name" size="20" value=<? echo $u_username ?> /></td><?php
?><td><input name="email" type="text" id="email" size="30" value=<? echo $u_email ?> /></td><?php
?><td><input name="level" type="text" id="userlevel" size="2" value=<? echo $u_userlevel ?> /></td><?php
?><td><input name="avatar" type="text" id="useravatar" size="20" value=<? echo $u_useravatar ?> /></td><?php
?><td><input name="rating" type="text" id="userrating" size="2" value=<? echo $u_userrating ?> /></td>
<input type="submit" name="Submit" value="Update" /> <br><?phpCode: Select all
$u_id=$_POST['u_id'];
$name=$_POST['name'];
$email=$_POST['email'];
$level=$_POST['level'];
$avatar=$_POST['avatar'];
$rating=$_POST['rating'];
echo "TEST";
echo $u_id;
echo $name;
echo $email;
echo $level;
echo $avatar;
echo $rating;Also, in the first page I noted if I have a username containing a blank it only fills out the infobox with the part before the blank so "peter pan" will be just peter... I assume i can fix this by replacing the blanks with some special char...but it is quite annoying. Does anyone know why it only inputs the first part of the string up until the blank?
Thanks