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.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

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'];

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.