Jump to content

[SOLVED] How do i get info from an sql databse with php?


JimD

Recommended Posts

I'm trying to get a php page to search a sql database to find what server the username is on and use that to redirect to a certain page depending on the server that user is on.

 

So this is how it should work.

1. User goes to remodesk.net/download/index.php

2. user types in thier username and presses the go button

3. That username is then transfered over to another php that remembers what they entered and then logs into the sql database which has only username and server No. in it.

4. then it searches for that username and then on the next column over which would be server no. it collects that number and lets say that user is on server 1 it redirects them to remodesk.net/download/serv1connect

 

If someone could code this that would be very great :D

 

Nevermind i figured it out myself:

 

<?php

$search = $_REQUEST["Username"];

 

mysql_connect("xxxxxx", "xxxxxx", "xxxxxxx") or die(mysql_error());

mysql_select_db("xxxxxx") or die(mysql_error());

$X = "That Username does not exist.";

 

$query = mysql_query("SELECT * FROM SERVER_DATA WHERE Username LIKE '%$search%' LIMIT 0, 30 ");

while ($row = mysql_fetch_array($query))

{

$variable1=$row["Server"];

print ("You are on Server: $variable1");

}

if (!$variable1)

{

print ("$X");

}

?>

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.