Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
page1
PHP
<?php 
							mysql_connect("localhost","root","");
mysql_select_db("mydatabase");
$sql="SELECT * FROM user";
$result=mysql_query($sql);
							while($row=mysql_fetch_array($result))							{

echo '<a  href="user_profile.php?variableName='.$row['userid'].'" style="text-decoration:none">'.$row['username'].'</a></form>';
}
?>

user_profile page
PHP
<?php
mysql_connect("localhost","root","");
mysql_select_db("mydatabase");
$sql="SELECT * FROM user where userid=".$_GET['variableName'];
$result=mysql_query($sql);
							while($row=mysql_fetch_array($result))							{
echo 'username:'.$row['name'];

}
?>


Is it right way or not if its right, why its not working, i facing problem to send information to another page. if it's not right way than please suggest me..I need your help.
Posted
Updated 12-Jul-12 16:04pm
v3

1 solution

The value is outside the double-quotes of the href attribute, which probably explains why it isn't working.

You need to sanitize the input on the user_profile page too - you can't just build an SQL query with whatever $_GET contains. Search for "SQL injection" and you should see what I mean.
 
Share this answer
 
Comments
barneyman 12-Jul-12 22:40pm    
+5 for remembering Bobby Tables

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900