Jump to content


Photo

Getting data from MySQL w/ validation.


  • Please log in to reply
2 replies to this topic

#1 lester2222

lester2222
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 05 April 2006 - 09:20 PM

Well.. ryt now im working with a WAP site.
Here's my site. [a href=\"http://www.wapthesis-ml.net\" target=\"_blank\"]WAPTHESIS[/a].

Ok here's the scenario, after a successful login, the user will prompt to choose
PRELIM MIDTERM and FINALS. I want to display the Data from DATABASE(Name,year_level,etc..) of that user who just made a successful login, what i meannot all the DATA in the database just for the user who made i successful login. Im Really stuck ryt now..
Hope someone help a Noob like me.
Thanks!

#2 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 05 April 2006 - 09:42 PM

can I suggest you show us your login script so we can have a clue what the problem is?


#3 lester2222

lester2222
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 05 April 2006 - 10:51 PM

<?PHP
//convert the field values to simple variables

$username = $_POST['username'];
$password = $_POST['password'];

//set the database connection variables

$dbHost = "localhost";
$dbUser = "";
$dbPass = "";
$dbDatabase = "wpthes_mobilegrades";

//connect to the database

$db = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("Error connecting to database.");

mysql_select_db("$dbDatabase", $db) or die ("Couldn't select the database.");

$result=mysql_query("select login_id from login where username='$username' AND password='$password'", $db);

//check that at least one row was returned

$rowCheck = mysql_num_rows($result);
if($rowCheck > 0){
while($row = mysql_fetch_array($result)){

  //successful login code will go here...
  header("Location: period.php");
  
  }

  }
  else {

  //if nothing is returned by the query, unsuccessful login code goes here...

  echo 'Incorrect login name or password. Please try again.';
  }
  
  ?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users