Jump to content

Recommended Posts

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.

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.

 

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?

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

?>

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.