General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

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 March 21st, 2004, 03:58 AM
114crowley 114crowley is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 1 114crowley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
passing variables thru pages

i am to make a login page with the following code
//login.php
<?php
include("includes/config.php");
//Basic Login Program
global $name;
$Auth=False; //for security
if($_POST){
//need to verify entered data for length, content, and exploits.
mysql_connect($dbserver,$dbreaduser,$dbreadpass) or die("Query failed: ". mysql_error());
mysql_select_db($db) or die("Query failed: " . mysql_error());
$query="SELECT * FROM ".$usertable." WHERE studentid = '".$_POST['studentid']."'";
$result=mysql_query($query) or die("Query failed: ".mysql_error());
$passwordresult=mysql_fetch_assoc($result);
$password=$passwordresult['pass'];
$status=$passwordresult['status'];
if ($_POST['pass'] == $password){
//set auth cookies

$name= $passwordresult['last'] . $passwordresult['first'];
$Auth=true;
}else{
print 'Invalid Username and or Password!';
$Auth=false;
die;
}

if($Auth==true){

header("Location: http://localhost/alpha/oasis/welcome.php");

}

}else{
print 'Please login...<br>';
print '<form action="login.php" method="POST">';
print 'Username: <input type="text" name="studentid" /><br>';
print 'Password: <input type="password" name="pass" /><br>';
print '<input type="submit">';
print '</form>';
}

?>

which gets redirected to welcome.php...
<?php
include("includes/config.php");
print "Welcome $name";
?>
it doesn't work...any work around would be appreciated..
thanks

Reply With Quote
  #2  
Old March 22nd, 2004, 11:06 AM
pentapenguin pentapenguin is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 51 pentapenguin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 7 sec
Reputation Power: 16
Is this what you are asking:
You want the variable $name to display on "welcome.php"?
If so you need to use sesions:
http://www.php.net/manual/en/ref.session.php

Reply With Quote
  #3  
Old March 23rd, 2004, 08:19 AM
Spongy's Avatar
Spongy Spongy is offline
Alternately High
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Hilversum, Netherlands
Posts: 223 Spongy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 56 m 41 sec
Reputation Power: 15
Send a message via MSN to Spongy
An easier way is to set the code in your welcome.php (I assume there is more...) in login.php
That way you don't have to use sessions. If you want the login credentials remembered then switch to sessions.
Play with it a little, untill you found a way that suits your needs.
Good luck and cheers,
__________________
Work to live, don't live to work

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > passing variables thru pages


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