PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 4th, 2004, 02:56 AM
franches franches is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 16 franches User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question $post

i know you will be able to help me with my probs.

could you please examine my code. this is the code that validates after the user enter username and password at the login page.



PHP:

<?php
session_start
();
$dbHost = "localhost"; // Database Connection Details - host
$dbUser = "root"; // Database Connection Details - username
$dbname = "TEST"; // Database Connection Details - database name

$username = $_POST['username'];
// Stores our inputted data in these variable names

$password = $_POST['password'];
// Stores our inputted data in these variable names

$db = mysql_connect($dbHost,$dbUser); // Connection Code
mysql_select_db($dbname); // Connects to database
$query = "(SELECT PIN, Password,Name FROM StaffTable WHERE PIN = '$username' AND Password = '$password')";
$result = mysql_query($query);

if(
mysql_num_rows($result)) {
$_SESSION['loggedin'] = 1;
header('Location: <a href="http://copernicus/rhodora/statuslog/trial/admin.php" target="_blank">http://copernicus/rhodora/statuslog/trial/admin.php</a>');
exit(); }
else {
header('Location: <a href="http://copernicus/rhodora/statuslog/trial/...?error=1" target="_blank">http://copernicus/rhodora/statuslog/trial/...?error=1</a>');
exit(); }
?>





and this is my page after successful login. and my problem is I am not able to display the username which is the ID number or PIN of the user and his/her name. i think i used the wrong code in calling the PIN and Name.

thank you in advance. I'll be looking forward for your response.




PHP:

<?php
session_start
();

if(!isset(
$_SESSION['loggedin'])) {
header('Location: <a href="http://copernicus/rhodora/statuslog/trial/...?error=1" target="_blank">http://copernicus/rhodora/statuslog/trial/...?error=1</a>');
exit();
}

?>
<head>
<script>
blah blah
</script>
</head>
<body>
<?php
mysql_connect
("localhost", "root")
or die(
"Unable to connect\n". mysql_error() );

mysql_select_db("TEST")
or die(
"Unable to select db ".mysql_error()."\n");


<
form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">

<
fieldset>
<
div>
<
label for="pin">PIN :</label> <? echo $username ?><br>
<label for="name">Name : </label><? echo $name ?> <br>
</div>

blah blah blah
</fieldset>
</form>
</body>
</html>


Reply With Quote
  #2  
Old October 4th, 2004, 03:54 AM
eddynazrul eddynazrul is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: 192.168.1.4
Posts: 21 eddynazrul User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Change your link a little bit..

Quote:
if(mysql_num_rows($result)) {
$_SESSION['loggedin'] = 1;
header('Location: <a href="http://copernicus/rhodora/statuslog/trial/admin.php?id='$username'" target="_blank">http://copernicus/rhodora/statuslog/trial/admin.php</a>');
exit(); }


In the admin page,query the data using this query,

Quote:
$query = "SELECT PIN, Password,Name FROM StaffTable WHERE PIN ='$id'";
$result = mysql_fetch_assoc($result);

$row = mysql_fetch_array($result);
$username = $row["PIN"];
$name = $row["Name"];

Hope this will help.

Reply With Quote
  #3  
Old October 4th, 2004, 10:28 PM
franches franches is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 16 franches User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks how ever i am confused what part in my admin.php i am going to insert this one.

i have attached my code so that you may be able to examine it or make some corrections to it. thanks and

i will be looking forward for your response.
Attached Files
File Type: zip statuslog.zip (2.2 KB, 496 views)

Reply With Quote
  #4  
Old October 4th, 2004, 10:59 PM
eddynazrul eddynazrul is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: 192.168.1.4
Posts: 21 eddynazrul User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Put it before you start the form

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > $post


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap