DarkWater Posted May 13, 2008 Share Posted May 13, 2008 $_GET['username'] Look at where you're sending the info in the URL in your .htaccess. Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 14, 2008 Author Share Posted May 14, 2008 nope soprry i have allready tired that,,, both $_GET['username'] and $_GET['user']... in my firends script i used this and it worked <?php session_start(); include "../settings.php"; if ( !empty($_GET['user']) ) { if ( ctype_alnum($_GET['user']) && strlen($_GET['user']) <= 10 ) { // further test and escape data } $username =($_GET['user']); $id = $_SESSION['user_id']; $get_username_value = get_username($id); $query = "INSERT INTO friend_requests (username ,by_user) VALUES('{$_GET[user]}', '$get_username_value')"; $result= mysql_query($query) or die("QUERY ERROR:<br />{$query}<br />" . mysql_error() ); echo "$username has been sent a request you must now wait for it to be accepted"; // useful in troubleshooting the SQL statement } else { echo "No request was made"; } ?> [code] [/code] Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 14, 2008 Author Share Posted May 14, 2008 arggg iv been tryin different things for ages an no chnage lol Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 14, 2008 Author Share Posted May 14, 2008 ok something not right is happening lol... when i run <? $user = $_GET['username']; echo $user;?> on its own it displays the users name on url BUT when i do this <?php session_start();?> <style type="text/css"> <!-- .message { color: #000000; font-family: Verdana; font-size: 10px;} .username { color: #FF9900 font-family: Verdana; font-size: 10px; font-weight: bold} .date { color: #707070; font-family: Verdana; font-size: 9px;} .forms { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10 px; color: #6CA05A; text-decoration: none; background-color: #CCCCCC; border-color: #6CA05A; border-style: solid; border: 1px} .submit { background-color: #CCCCCC; border-color: #6CA05A; color: #2A343C; font-family: Verdana; font-size: 10px; border-style: solid; border 1 px;} --> </style> </head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="padding: 2px"> <?php // If submitted if($_POST['submit']) { // Verify if the fields were filled. if(!$_POST['message']) { echo 'Error, You need to post a Message!'; die; } // Date format $date = date("d/m/y"); // http://www.php.net/date // Assign variables of the forms // Connect to the database include('../../settings.php'); $id = $_SESSION['user_id']; $username = get_username($id); $user = $_GET['username']; $message = $_POST['message']; $ip = $_SERVER['REMOTE_ADDR']; // Insert the info in the shoutbox table. $query = "INSERT INTO shoutbox (`user`, username, message, date, ip) VALUES ('$user','$username','$message','$date','$ip')"or die(mysql_error()); mysql_query($query); // close connection // Show message to let them return to the shoutbox ?> <div align="center">Thank you for submitting.<br> Return to the <a href="shoutbox.php">shoutbox</a>! <?php // If NOT submitted } else { $query = "SELECT * FROM shoutbox ORDER BY id DESC LIMIT 10"; $result = mysql_query($query); // Create a table ?> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <? // Run a While loop for the rows while($c = mysql_fetch_array($result)) { ?> <tr> <td> <? echo $c[username] ?> says: <div align="justify"><? echo $c[message] ?></div> </td> </tr> <tr><td>on <? echo $c[date] ?> <hr noshade="noshade" size="1" style="border-style: dashed" color="#000000" /></td></tr> <? } ?> </table> <form method="post" action="box.php"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td>Message :</td> <td><input type="text" name="message" class="forms"></td> </tr> <tr> <td colspan="2"><input type="submit" name="submit" value="Speak!" class="subtmit"></td> </tr> </table> </form> <?php } ?> </body> </html> it does not display the username within the url :S even if i echo $user... strange Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 14, 2008 Author Share Posted May 14, 2008 bmp Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 14, 2008 Author Share Posted May 14, 2008 ok above if($_POST['submit']) i can crap the name via $_GET['username'] but anything below then i cannot echo it...how comes?? <?php $user = isset($_GET['username'])? $_GET['username'] : ""; //echo $user; this displays the user name but anything below it does not if($_POST['submit']) { // Verify if the fields were filled. if(!$_POST['message']) { echo 'Error, You need to post a Message!'; die; } // Date format $date = date("d/m/y"); // http://www.php.net/date // Assign variables of the forms // Connect to the database include('../settings.php'); $id = $_SESSION['user_id']; $username = get_username($id); $message = $_POST['message']; $ip = $_SERVER['REMOTE_ADDR']; // Insert the info in the shoutbox table. $query = "INSERT INTO shoutbox (`user`, username, message, date, ip) VALUES ('$user','$username','$message','$date','$ip')"; $result= mysql_query($query) or die("QUERY ERROR:<br />{$query}<br />" . mysql_error() ); mysql_query($query); // close connection // Show message to let them return to the shoutbox ?> Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 14, 2008 Author Share Posted May 14, 2008 ok i have been thinkin... should my post look something liek this <form method="post" action="box.php?$user=<?php $_GET['username'] ?> "> Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 14, 2008 Author Share Posted May 14, 2008 ok i tried it and it will not display the user name at al i dont get whats going on so for 1 last attempt lol im going to fully expalin whats going on ok above if($_POST['submit']) i can grab the name via $_GET['username'] but anything below then i cannot echo it...how comes?? PHP Code: get username gets the name of the profile form the url due to this RewriteRule ^([^/.]+)/?$ members/index.php?page=profile&username=$1 <?php session_start(); ?> <?php $user = isset($_GET['username'])? $_GET['username'] : ""; //echo $user; this displays the user name but anything below it does not if($_POST['submit']) { // Verify if the fields were filled. if(!$_POST['message']) { echo 'Error, You need to post a Message!'; die; } // Date format $date = date("d/m/y"); // http://www.php.net/date // Assign variables of the forms // Connect to the database include('../settings.php'); $user1 = $_POST['usersaccount']; $id = $_SESSION['user_id']; $username = get_username($id); $message = $_POST['message']; $ip = $_SERVER['REMOTE_ADDR']; // Insert the info in the shoutbox table. $query = "INSERT INTO shoutbox (`user`, username, message, date, ip) VALUES ('$user1','$username','$message','$date','$ip')"; mysql_query($query); // close connection // Show message to let them return to the shoutbox ?> <div align="center">Thank you for submitting.<br> Return to the <a href="shoutbox.php">shoutbox</a>! <?php // If NOT submitted } else { $query = "SELECT * FROM shoutbox ORDER BY id DESC LIMIT 3"; $result = mysql_query($query); // Create a table ?> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <? // Run a While loop for the rows while($c = mysql_fetch_array($result)) { ?> <tr> <td> <? echo $c[username] ?> says: <div align="justify"><? echo $c[message] ?></div> </td> </tr> <tr><td>on <? echo $c[date] ?> <hr noshade="noshade" size="1" style="border-style: dashed" color="#000000" /></td></tr> <? } ?> </table> <form method="post" action="box.php"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td>Message :</td> <td><input type="text" name="message" class="forms"><input type="hidden" id="usersaccount" name="usersaccount" value="<?php $user ;?>" /></td> </tr> <tr> <td colspan="2"><input type="submit" name="submit" value="Speak!" class="subtmit"></td> </tr> </table> </form> <?php } ?> </body> </html> is it because i need to do somethingwith action="box.php" .... this page is actually box.php itself so allits really doing is sending it back to this page.... the page i have included this script on has the name in the url... if i went to just mywebsite.com/box.php it would look like that so i included it on http://www.mywebsite.com/username i thought i best tell you all this as it might be very improtant lol Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 15, 2008 Author Share Posted May 15, 2008 bmpo Quote Link to comment Share on other sites More sharing options...
redarrow Posted May 15, 2008 Share Posted May 15, 2008 try now mate........ <?php session_start(); ?> <?php $user = isset($_GET['username'])? $_GET['username'] : ""; //echo $user; this displays the user name but anything below it does not if($_POST['submit']) { // Verify if the fields were filled. if(!$_POST['message']) { echo 'Error, You need to post a Message!'; die; } // Date format $date = date("d/m/y"); // http://www.php.net/date // Assign variables of the forms // Connect to the database include('../settings.php'); $user1 = $_POST['usersaccount']; $id = $_SESSION['user_id']; $username = get_username($id); $message = $_POST['message']; $ip = $_SERVER['REMOTE_ADDR']; // Insert the info in the shoutbox table. $query = "INSERT INTO shoutbox (`user`, username, message, date, ip) VALUES ('$user1','$username','$message','$date','$ip')"; mysql_query($query); // close connection // Show message to let them return to the shoutbox ?> <div align="center">Thank you for submitting.<br> Return to the <a href="shoutbox.php">shoutbox</a>! <?php // If NOT submitted } else { $query = "SELECT * FROM shoutbox ORDER BY id DESC LIMIT 3"; $result = mysql_query($query); // Create a table ?> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <? // Run a While loop for the rows while($c = mysql_fetch_array($result)) { ?> <tr> <td> <?php echo $c['username']; ?> says: <div align="justify"><?php echo $c['message']; ?></div> </td> </tr> <tr><td>on <?php echo $c['date']; ?> <hr noshade="noshade" size="1" style="border-style: dashed" color="#000000" /></td></tr> <? } ?> </table> <form method="POST" action="box.php"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td>Message :</td> <td><input type="text" name="message" class="forms"><input type="hidden" id="usersaccount" name="usersaccount" value="<?php $user ;?>" /></td> </tr> <tr> <td colspan="2"><input type="submit" name="submit" value="Speak!" class="subtmit"></td> </tr> </table> </form> <?php } ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 15, 2008 Author Share Posted May 15, 2008 nope that didnt work pal... for some reason its not grabbing the username from the url unless its all doen out of this script :S 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.