beccaod Posted June 22, 2007 Share Posted June 22, 2007 I'm trying to get this to work so that each person is defined in a certain division and when they log in it will automatically direct them to their part of the website for that division. I have the division stored in the database then would like to have that added directly to the url so it links to different folders for each division. This is what I have so far. I have connected and closed in another part of the code. $sql = mysql_query ("SELECT `division` FROM `register` WHERE login_username = '$user' AND login_userpass = '. md5($passA).'"); if ($env['user_id'] > 0) { echo 'You are logged in as: '; echo '<b>'.$env['user'].'</b>'; echo ' '; echo 'Click <a href="'.$env['nav_path'].'welcome/">here</a> to see your profile.'; echo ' '; echo 'Remember to <a ref="'.$env['nav_path'].'logout.php">Log Out</a> When you\'re done!'; } else { echo '<form action="'.$env['nav_path'].'/stuff/'.$sql.'/Copy of office.php" method="post">'; echo ''; echo 'Username: <input type="text" name="login_username" /> '; echo 'Password: <input type="password" name="login_userpass" /> '; echo '<input type="submit" name="login" value="Log In" />'; echo '</form>'; } No matter what way I put the $sql into the url, it won't show up correctly. It either puts $sql in the url or takes it out completely. Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/56707-retrieving-data-from-website-and-then-posting-in-url/ Share on other sites More sharing options...
GingerRobot Posted June 22, 2007 Share Posted June 22, 2007 What exactly is it that you're trying to put in the url string? The text of the query? Or the result? Im a bit confused as to what you're trying to achieve. Quote Link to comment https://forums.phpfreaks.com/topic/56707-retrieving-data-from-website-and-then-posting-in-url/#findComment-280081 Share on other sites More sharing options...
beccaod Posted June 22, 2007 Author Share Posted June 22, 2007 I'm trying to put the string of what is set in the division row of the database. So the text from the query. Quote Link to comment https://forums.phpfreaks.com/topic/56707-retrieving-data-from-website-and-then-posting-in-url/#findComment-280093 Share on other sites More sharing options...
GingerRobot Posted June 22, 2007 Share Posted June 22, 2007 So you want to put say the text: "SELECT `division` FROM `register` WHERE login_username = '$user' AND login_userpass = '. md5($passA).'" in your url string? (obviously with the contents of the variables) if so, i think you need to change this line: $sql = mysql_query ("SELECT `division` FROM `register` WHERE login_username = '$user' AND login_userpass = '. md5($passA).'"); to: $sql = urlencode("SELECT `division` FROM `register` WHERE login_username = '$user' AND login_userpass = '. md5($passA).'"); You will then need the urldecode function If you're wanting to pass the text of the query, you can't perform the query and pass that variable. And i dont think it'll like it if you dont encode that what with all the quotes. Quote Link to comment https://forums.phpfreaks.com/topic/56707-retrieving-data-from-website-and-then-posting-in-url/#findComment-280095 Share on other sites More sharing options...
beccaod Posted June 22, 2007 Author Share Posted June 22, 2007 Not exactly what I'm trying to get it to do. I'm trying to have it access the database, go into the row called division for a certain username and password and then come back with the text that is stored in division. So say I have a person called "me" with a password of "good" and a division of "business". I would like it to access the database when the person logs in and know that their division is "business" so it will link them to the main page of the business section. So in the end I want the url to read www.crazy.com/stuff/business/Copy of office.php but right now the way I've got it it just goes to www.crazy.com/stuff/Copy of Office.php and if I take out the '.$sql.' and just put $sql then it gives me www.crazy.com/stuff/$sql/Copy of Office.php Am I making sense? Quote Link to comment https://forums.phpfreaks.com/topic/56707-retrieving-data-from-website-and-then-posting-in-url/#findComment-280108 Share on other sites More sharing options...
GingerRobot Posted June 22, 2007 Share Posted June 22, 2007 Ah right, i see, well your syntax for the echo looks ok - you just need to retreive the actual text after performing the query: <?php $sql = mysql_query ("SELECT `division` FROM `register` WHERE login_username = '$user' AND login_userpass = '. md5($passA).'"); $division = mysql_result($sql,0,"devision");//you forgot this bit if ($env['user_id'] > 0) { echo 'You are logged in as: '; echo ''.$env['user'].''; echo ' '; echo 'Click <a href="'.$env['nav_path'].'welcome/">here[/url] to see your profile.'; echo ' '; echo 'Remember to <a ref="'.$env['nav_path'].'logout.php">Log Out[/url] When you\'re done!'; } else { echo '<form action="'.$env['nav_path'].'/stuff/'.$division.'/Copy of office.php" method="post">';//and changed this line to reflect new variable echo ''; echo 'Username: <input type="text" name="login_username" /> '; echo 'Password: <input type="password" name="login_userpass" /> '; echo '<input type="submit" name="login" value="Log In" />'; echo '</form>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/56707-retrieving-data-from-website-and-then-posting-in-url/#findComment-280393 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.