markcunningham07 Posted July 16, 2010 Share Posted July 16, 2010 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. Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted July 16, 2010 Share Posted July 16, 2010 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']; Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted July 16, 2010 Share Posted July 16, 2010 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. Quote Link to comment Share on other sites More sharing options...
markcunningham07 Posted July 16, 2010 Author Share Posted July 16, 2010 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 Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted July 16, 2010 Share Posted July 16, 2010 $username = mysql_real_escape_string($_GET['username']); $result = mysql_query("SELECT * FROM forum WHERE UserName='{$username}'); Quote Link to comment Share on other sites More sharing options...
hcdarkmage Posted July 16, 2010 Share Posted July 16, 2010 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. Quote Link to comment Share on other sites More sharing options...
markcunningham07 Posted July 16, 2010 Author Share Posted July 16, 2010 I am new to PHP, can some one help me through MSN. i appreciate it a lot MSN : markcunningham07[at]hotmail.com Quote Link to comment Share on other sites More sharing options...
markcunningham07 Posted July 16, 2010 Author Share Posted July 16, 2010 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 Quote Link to comment Share on other sites More sharing options...
markcunningham07 Posted July 17, 2010 Author Share Posted July 17, 2010 Thanks for all your support Problem Solved every once answer was right it was me did the mistake. anyway, now its all done, thanks again. appreciate all help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.