Welcome Guest ( Log In | Register)



 
Closed TopicStart new topic
> [php/mysql]id Trouble [resolved]
coldasice
post Dec 22 2007, 11:39 AM
Post #1


Newbie [Level 2]
**

Group: Members
Posts: 34
Joined: 10-December 07
From: Norway
Member No.: 54,556



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

This post has been edited by coldasice: Dec 22 2007, 12:02 PM
Go to the top of the page
 
+Quote Post
rvalkass
post Dec 22 2007, 12:02 PM
Post #2


apt-get moo
Group Icon

Group: [MODERATOR]
Posts: 2,056
Joined: 28-May 05
From: Hertfordshire, England
Member No.: 7,593
Spam Patrol



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");
Go to the top of the page
 
+Quote Post
coldasice
post Dec 22 2007, 12:17 PM
Post #3


Newbie [Level 2]
**

Group: Members
Posts: 34
Joined: 10-December 07
From: Norway
Member No.: 54,556



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]
Go to the top of the page
 
+Quote Post
truefusion
post Dec 22 2007, 02:07 PM
Post #4


Ephesians 6:10-17
Group Icon

Group: [MODERATOR]
Posts: 1,868
Joined: 22-June 05
From: The World of Gentoo
Member No.: 8,528
T17 GFX Crew



Topic is resolved.

Please PM any moderator to continue this discussion. Until then, this topic is closed.
Go to the top of the page
 
+Quote Post

Closed TopicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Problem On Mysql "order By"(5)
  2. Increment A Mysql Column(6)
  3. Can You Add Images Into A Mysql Database?(20)
  4. Creating Profiles In Php/mysql ?(7)
  5. Php Search Engine Script For Mysql Database(11)
  6. How To Delete A Row In Mysql.(4)
  7. Importing .csv Into Mysql Database(6)
  8. Editing Information In A Mysql Database And Deleting Rows(5)
  9. Putting Data Of 2 Pages In Mysql At Once(1)
  10. Mysql Query(2)
  11. Simple Mysql Query Limiting(9)
  12. Some Mysql Basics(4)
  13. Php, Mysql, Apache(4)
  14. Php And Mysql Applications(3)
  15. Getting Php 5 To Work With Mysql(0)
  1. Problem With A Mysql Join(2)
  2. The Artists Tutorials :mysql Basic Commands(0)
  3. [mysql]get Id Of Loged In User?(7)
  4. [mysql/php]need Som Basic Help(13)
  5. Mysql Won't Update(4)
  6. Php + Mysql Question!(4)
  7. Tools Needed!(9)
  8. Best Sites For Learning Php-mysql(4)
  9. Php And Mysql Programming(2)
  10. Best Php And Mysql Editor For Noobs(6)
  11. Html Form!(4)
  12. Mysql Error(3)
  13. Create Table - Mysql Code - Help(1)


 



- Lo-Fi Version Time is now: 27th July 2008 - 02:14 AM