Nov 21, 2009

[php/mysql]id Trouble [resolved]

free web hosting
Open Discussion > MODERATED AREA > Computers > Programming Languages > PHP Programming

[php/mysql]id Trouble [resolved]

coldasice
CODE
<?php
session_start();
include "database.php";
if (!$_SESSION["valid_user"] || $_SESSION['userlevel'] < 9)
{
// User not logged in, redirect to login page
Header("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 script

and i want to transfer this over here.. by using id...


CODE
<?php
session_start();
include "database.php";
if (!$_SESSION["valid_user"] || $_SESSION['userlevel'] < 9)
{
// User not logged in, redirect to login page
Header("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

 

 

 


Comment/Reply (w/o sign-up)

rvalkass
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:

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:

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

Comment/Reply (w/o sign-up)

coldasice
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 smile.gif



[SOLVED]

Comment/Reply (w/o sign-up)

truefusion
Topic is resolved.

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

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : Phpmysqlid Resolved


    Looking for , php, mysql, id, trouble

Searching Video's for , php, mysql, id, trouble
See Also,
advertisement


[php/mysql]id Trouble [resolved]

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com