Jump to content

Quick Question


jimmyp3016

Recommended Posts

here is my code:

[code]

$user = $_GET['usr'];
$db = @mysql_connect("$localhost", "$databaseuser", "$databasepasswd");
@mysql_select_db("$databasename",$db);
$sql = "SELECT * FROM table WHERE user='$user'";
$result = mysql_query($sql,$db);
if (mysql_num_rows($result) != 0) {

$firstname = mysql_result($result, 0, "firstname");
$lastname = mysql_result($result, 0, "lastname");
}

[/code]
Link to comment
https://forums.phpfreaks.com/topic/15158-quick-question/#findComment-61065
Share on other sites

[code=php:0]
$user = $_GET['usr'];
$db = @mysql_connect("$localhost", "$databaseuser", "$databasepasswd");
@mysql_select_db("$databasename",$db);
$sql = "SELECT * FROM table WHERE user='$user'";
$result = mysql_query($sql,$db);
if (mysql_num_rows($result) != 0) {

$firstname = mysql_result($result, 0, "firstname");
$lastname = mysql_result($result, 0, "lastname");
} else {
  header("Location: usernotfound.php"); // <--- put the page you wish to direct to here.
}
[/code]
Link to comment
https://forums.phpfreaks.com/topic/15158-quick-question/#findComment-61066
Share on other sites

It's not as simple as just throwing an answer at you.

1. You need to know what table to lookup.
2. How are users handles in your curent script? What are you using as criteria? Userid? Username?
3. You then need a conditional statement that executes your redirection, based on the results.
4. What method is your current code using? Is it using OOP? The database query might look diferent if that's the case.

You have any example code?

http://www.php.net <--Very helpful site. Use it.
Link to comment
https://forums.phpfreaks.com/topic/15158-quick-question/#findComment-61067
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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