Jump to content

Get content from database instead using GET function to get content from URL


Recommended Posts

Please read carefully, any help accepted thankfully.

Assume

User Name : picaso99

Firstname : martin

Age : 34

Coming to my website

 

When user came to my website

 

They fill required form

IE :

Nick name:  <input type="text" name="firstname" />

Channel Name: <input type="text" name=" UserName " />

Uniq ID: <input type="text" name=" Age "  />

 

Then they submit, which will post information they entered on forms to my database which contain following tables (FirstName, UserName, Age)

 

Also After submitting they are redirected to a page which URL is

 

http://mydomain.com/flash/test.php?username=picaso99

 

Page generated using following PHP code:

 

http://mydomain.com/flash/test.php?username=<?php

echo $_GET["username"];

?>

 

Which gives an output:

 

http://mydomain.com/flash/test.php?username=picaso99

 

 

Now users URL on address bar is: http://mydomain.com/flash/test.php?username=picaso99

 

http://mydomain.com/flash/test.php file contain a flash ad for every user which I use to do lot of things

 

Please take give attention to following 2 links on file content below.

 

echo $_GET["UserName "];

echo “Users First name”;

 

All the file content of test.php below:

 

<?php

echo "<script type='text/javascript' src='swfobject.js'></script>";

echo "<div id='player'>This text will be replaced</div>";

echo "<script type='text/javascript'>";

echo "var so = new SWFObject('player.swf','mpl','480','360','9');";

echo "so.addParam('allowfullscreen','true');";

echo "so.addParam('allowscriptaccess','always');";

echo "so.addParam('wmode','opaque');";

echo "so.addVariable('plugins','livestream-1');";

echo "so.addParam('flashvars','&file=";

echo $_GET["UserName "];

echo “.flv&streamer=”;

echo “Users First name”;

echo “&stretching=exactfit&logo.file=logo.png&logo.hide=false&logo.position=top-left&logo.link=http://www.tvnsports.com&autostart=true');";

echo "so.write('player');";

echo "</script>";

?>

 

In above code:

echo “Users First name”;

 

want to get Users First name by connecting to database not from URL on address bar

so I can not use

echo $_GET["FirstName "];

to get user name since http://mydomain.com/flash/test.php?username=picaso99 only have user name.

 

Due to security reason I cannot put first name on URL

 

I Do NOT want to do following

Make URL http://mydomain.com/flash/test.php?username=picaso99&firstname= martin

Then use echo $_GET["firstname "];

 

To get first name of the user to

echo “Users First name”; <--located inside the test.php.

 

I want to connect to database and get it from there.

 

Please please help me out to figure this out. I am lost on about problem for 3 days not, I made lots of post here to find a way to solve this but couldn’t figure it out.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Assuming MySQL:

 

$conn = mysql_connect('localhost', 'username', 'password');
$result = mysql_query("SELECT `FirstName` from table_name WHERE `UserName` = '" . $_GET['username'] . "' LIMIT 1";
$row = mysql_fetch_assoc($result);
echo $row['FirstName'];

Immediately after inserting the new user into the database, use mysql_insert_id() to retrieve the auto-increment index field value. Set that as a $_SESSION var, and use it for all further database queries. Eliminates the need to use GET vars in the URL entirely.

Please refer to code below, I came up with following code but cannot find a way to get username from address bar http://mydomain.com/flash/test.php?username=picaso99& using

 

echo $_GET["username "];

 

instead of the red highlighted content

 

$result = mysql_query("SELECT * FROM forum

WHERE UserName=' How to get username from browser address to here'");

 

 

<?php

echo "<script type='text/javascript' src='swfobject.js'></script>";

echo "<div id='player'>This text will be replaced</div>";

echo "<script type='text/javascript'>";

echo "var so = new SWFObject('player.swf','mpl','480','360','9');";

echo "so.addParam('allowfullscreen','true');";

echo "so.addParam('allowscriptaccess','always');";

echo "so.addParam('wmode','opaque');";

echo "so.addVariable('plugins','livestream-1');";

echo "so.addParam('flashvars','&file=";

echo $_GET["channelname"];

echo ".flv&streamer=";

$con = mysql_connect("localhost","database","password");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

mysql_select_db("forum", $con);

 

$result = mysql_query("SELECT * FROM forum

WHERE UserName=' How to get username from browser address to here'");

 

while($row = mysql_fetch_array($result))

  {

  echo $row['FirstName'];

  }

echo "&stretching=exactfit&logo.file=logo.png&logo.hide=false&logo.position=top-left&logo.link=http://www.mydomain.com&autostart=true');";

echo "so.write('player');";

echo "</script>";

?>

 

Whole point of geting first name from MySQL database so when i delete the user, there is nothing to display as firstname so the flash file dont work

Please refer to code below, I came up with following code but cannot find a way to get username from address bar http://mydomain.com/flash/test.php?username=picaso99& using

echo $_GET["username "];

instead of the red highlighted content

$result = mysql_query("SELECT * FROM forum
WHERE UserName=' How to get username from browser address to here'");


<?php
echo "<script type='text/javascript' src='swfobject.js'></script>";
echo "<div id='player'>This text will be replaced</div>";
echo "<script type='text/javascript'>";
echo "var so = new SWFObject('player.swf','mpl','480','360','9');";
echo "so.addParam('allowfullscreen','true');";
echo "so.addParam('allowscriptaccess','always');";
echo "so.addParam('wmode','opaque');";
echo "so.addVariable('plugins','livestream-1');";
echo "so.addParam('flashvars','&file=";
echo $_GET["channelname"];
echo ".flv&streamer=";
$con = mysql_connect("localhost","database","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("forum", $con);

$result = mysql_query("SELECT * FROM forum
WHERE UserName=' How to get username from browser address to here'");

while($row = mysql_fetch_array($result))
  {
  echo $row['FirstName'];
  }
echo "&stretching=exactfit&logo.file=logo.png&logo.hide=false&logo.position=top-left&logo.link=http://www.mydomain.com&autostart=true');";
echo "so.write('player');";
echo "</script>";
?>

 

Whole point of geting first name from MySQL database so when i delete the user, there is nothing to display as firstname so the flash file dont work

 

Simple enough . . . maybe.

 

$uName = $_GET['username'];  //<--- Set the get to a variable
$result = mysql_query("SELECT * FROM forum
WHERE UserName='".$uname."'");  //<--- Insert variable where needed

 

EDIT: Or what Pikachu beat me to say.

I set up everything for a demo

 

Please take a look at URL below it gives you good idea of what i am asking for.

 

 

http://tvhindi.com/flashplayer/

 

Thank for everyone who try to help me, hope someone help me soon

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.