Jump to content

Getting data from MySQL w/ validation.


lester2222

Recommended Posts

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!
Link to comment
Share on other sites

[code]<?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.';
  }
  
  ?> [/code]
Link to comment
Share on other sites

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.