Jump to content
xisto Community
coldasice

[php/mysql]id Trouble [resolved]

Recommended Posts

<?phpsession_start(); include "database.php";if (!$_SESSION["valid_user"]  || $_SESSION['userlevel'] < 9){// User not logged in, redirect to login pageHeader("Location: main.php");}$result = mysql_query("select * from users order by id asc");while($r=mysql_fetch_array($result)){$username=$r["username"];$info=$r["info"];$msn=$r['msn'];$email=$r["email"];$id=$r["id"];$password=$r["password"];$userlevel=$r["userlevel"];echo "<table width='100%' border=0 cellpadding=1 cellspacing=0>      <form  name=login action='edit.admin.php?cmd=$id' method=post>       <tr>        <td>user ID</td>        <td><input  type=text name=userID value='$id' disabled='disabled' style='width:150;' id='userID'></td>      </tr>      <tr>        <td>User Level</td>        <td><input  type=text name=UserLevel value='$userlevel' disabled='disabled' style='width:150;' id='UserLevel'></td>      </tr>      <tr>        <td>Username</td>        <td><input  type=text name=username value='$username' disabled='disabled' style='width:150;' id='username'></td>      </tr>      <tr>        <td>Password</td>        <td><input  type=text name=password value='$password' disabled='disabled'  style='width:223;' id='password'></td>      </tr>      <tr>   <td width=80>Email: </td>  <td width='160'><input  type=text name=email value='$email' disabled='disabled' style='width:150;'></td>  </tr>  <tr>  <td>MSN: </td>  <td><input type=text name=msn disabled='disabled' value='$msn' style='width:150'></td>   </tr>  	   <tr>         <td>Info: </td>  <td><textarea rows='10' cols='45' disabled='disabled' name='info' id='info'>$info</textarea></td>        </tr>          </tr>		 <td><input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Edit\" /></td>       </form>      </table><br /> ---------------------<br />";}echo "<p><a href=\"member.php\">Click here to go back to info page!</a></p>";?>

this is my main scriptand i want to transfer this over here.. by using id...

<?phpsession_start(); include "database.php";if (!$_SESSION["valid_user"]  || $_SESSION['userlevel'] < 9){// User not logged in, redirect to login pageHeader("Location: main.php");}$result = mysql_query("select * from users where id=id2'");$r = mysql_fetch_array ($result);$username=$r["username"];$info=$r["info"];$msn=$r['msn'];$email=$r["email"];$id=$r["id"];$password=$r["password"];$userlevel=$r["userlevel"];echo "woot :". $id;echo "<table width=\"100%\" border=0 cellpadding=1 cellspacing=0>      <form  name=login action='$php_self?' method=post>       <tr>        <td>user ID</td>        <td><input   type=text name=userID value='$id' disabled='disabled' style='width:150;' id='userID'></td>      </tr>      <tr>        <td>User Level</td>        <td><input   type=text name=UserLevel value='$userlevel'  style='width:150;' id='UserLevel'></td>      </tr>      <tr>        <td>Username</td>        <td><input   type=text name=username value='$username' style='width:150;' id='username'></td>      </tr>      <tr>        <td>Password</td>        <td><input   type=text name=password value='$password'   style='width:223;' id='password'></td>      </tr>      <tr>   <td width=80>Email: </td>  <td width='160'><input   type=text name=email value='$email'  style='width:150;'></td>  </tr>  <tr>  <td>MSN: </td>  <td><input type=text name=msn  value='$msn' style='width:150'></td>   </tr>  	   <tr>         <td>Info: </td>  <td><textarea rows='10' cols='45'  name='info' id='info'>$info</textarea></td>        </tr>          </tr>		 <td><label>   <input type='submit' name='edit' id='edit' value='edit'> </label></td>       </form>      </table>";echo "<p><a href=\"member.php\">Click here to go back to info page!</a></p>";?>

this is where i want that from the first inprinted ;O

Edited by coldasice (see edit history)

Share this post


Link to post
Share on other sites

Your second script never actually reads any POST data. You run the MySQL query looking for a hard coded ID value (id2). If you want to get the information from the previous form, you need to use this code:

$id = $_POST['userID'];

That sets $id equal to whatever ID is passed through by the form. Then you need to adjust your MySQL query so that it looks for that ID in the database:

$result = mysql_query("SELECT * FROM users WHERE id = $id");

Share this post


Link to post
Share on other sites

thanks for ur anser...

 

well u see..... i posted it with a id named cmd.... lol so when i used id it didnt work.. but now it works.. and i dont know why in the secound script it wasnt there :P

 

 

 

[sOLVED]

Share this post


Link to post
Share on other sites

Topic is resolved.Please PM any moderator to continue this discussion. Until then, this topic is closed.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.