a problem i cant seem to get around

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Hehehe

Well, i ain't just the PIMP DADDY in PHP

In my current position i do the following:-

The bulk of the time - i'm the head of web design/development
PHP programming
MySQL
MsSQL
CGI/PERL Programming
HTML
CSS
Flash + Actionscript
Shockwave + Lingo
+ others

Other times
PC/Mac System and network support
Hardware support
etc etc

Unfortuantely do this as well, i shouldn't be so multi-talented :)
Graphic Design
- Brochures
- Business Cards
- Logos
- etc etc

Recruitment Advertising
- Recruitment ads for large companies that appear in papers such as
- The Guardian
- The Times

Also have done VR design and some other 3D stuff.

But hey, it's not a competition :)

Mark
Last edited by JayBird on Wed Dec 10, 2003 9:27 am, edited 1 time in total.
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

if it was, ive just finished last :roll:

VR design : something i want to do, unfortunately the market doesnt seem to be going anywhere with it :/
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

malcolmboston wrote:VR design : something i want to do, unfortunately the market doesnt seem to be going anywhere with it :/
It is really cool. We had a VR studio with a Hydraulic VR Chair. We built a Grand Prix world that when you sat in the chair, you actually felt the G-Force like as if you were sat in the Formula 1 car.

Spent most of the time messing around with it, using the chair like a bucking bronco :)

Mark
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

sounds v-cool

and sounds like something id like to spend time with the missus on! 8)

jesus, this is a PHP forums!, not sordid sex games forum

<--- back to topic, any idea how i can get a login form to work and pass a variable at the same time?
User avatar
aquila125
Forum Commoner
Posts: 96
Joined: Tue Dec 09, 2003 10:39 am
Location: Belgium

Post by aquila125 »

why not use sessions?

if the user enters his username/password and they are correct, you just register a session variable:

$_SESSION['logged_in']=1;
$_SESSION['userid']=$userid;

(before you should'v registered $_SESSION['logged_in']=0 and check on this value if you want to know if the user is logged in)

with this method you always have the userid at hand...
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

okay, you have your login page and presumably you will be submitting the form using the POST method.

On the next page, to access the username you would just do this.

Code: Select all

$username = $_POST['username'];
or, store it in the session

Code: Select all

$_SESSION['username'] = $_POST['username'];
Not forgetting your session_start()

That's presuming your username form element was called 'username'.

Mark
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

thats is exactly my point it will not work that way

currently (dont know if any of you guys do it) i use DWMX to create the user login it does it, no matter what i do it will NOT send the var, unless i turn reg_globals on, then it does work

ive tried 3 diff ways of getting it, none work
followed tutorials in PHP books, did not work

it just wont do it

it is worth noting that my action on my form is used by the code, so i cannot tell it to pass the var to page 2, which i assume this is the problem, but surely PHP is not so linear that after setting a var you must go to the next page to retrieve it (i used to be able to retrieve it from any page when using cookies to do it, which worked so easily it was ridiculious, however due to security reasons and need to use sessions this no longer is a viable solution.

If anyone has used DWMX to do this thenn PLEASE tell me how to get around this!

any ideas?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

malcolmboston wrote:
it is worth noting that my action on my form is used by the code...
Not sure what you mean by that mate.

I use DWMX for all my apps, so i should be able to help but i don't quite fully understand your problem at the moment.

Mark
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

ok thank you for your time, its very much appreciated

if you have ever encountered DW php authenticication behaviours you will know what i mean

i am currently not at my comp so i cant show , unfortunately

you can download it here
http://www.macromedia.com/cfusion/excha ... 24&catid=0

i use it for quickness

when you create the login behaviour it decides to change the action of the form, if you edit it, it ceases to work

try it out this i believe is why it is happening, i need to write my own script really but dont have time
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

is this what the code roughly looks like?

Code: Select all

<?php
// *** Start the session
session_start();
// *** Validate request to log in to this site.
$FF_LoginAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING']) && $HTTP_SERVER_VARS['QUERY_STRING']!="") $FF_LoginAction .= "?".htmlentities($HTTP_SERVER_VARS['QUERY_STRING']);
if (isset($HTTP_POST_VARS['username'])) {
  $FF_valUsername=$HTTP_POST_VARS['username'];
  $FF_valPassword=$HTTP_POST_VARS['password'];
  $FF_fldUserAuthorization="";
  $FF_redirectLoginSuccess="/content/template.htm";
  $FF_redirectLoginFailed="/content/tractor_series/the_range/6140_6185/6140_6185_1.htm";
  $FF_rsUser_Source="SELECT id, password ";
  if ($FF_fldUserAuthorization != "") $FF_rsUser_Source .= "," . $FF_fldUserAuthorization;
  $FF_rsUser_Source .= " FROM ibf_members WHERE id='" . $FF_valUsername . "' AND password='" . $FF_valPassword . "'";
  mysql_select_db($database_LaptopDB, $LaptopDB);
  $FF_rsUser=mysql_query($FF_rsUser_Source, $LaptopDB) or die(mysql_error());
  $row_FF_rsUser = mysql_fetch_assoc($FF_rsUser);
  if(mysql_num_rows($FF_rsUser) > 0) {
    // username and password match - this is a valid user
    $MM_Username=$FF_valUsername;
    session_register("MM_Username");
    if ($FF_fldUserAuthorization != "") {
      $MM_UserAuthorization=$row_FF_rsUser[$FF_fldUserAuthorization];
    } else {
      $MM_UserAuthorization="";
    }
    session_register("MM_UserAuthorization");
    if (isset($accessdenied) && false) {
      $FF_redirectLoginSuccess = $accessdenied;
    }
    mysql_free_result($FF_rsUser);
    session_register("FF_login_failed");
	$FF_login_failed = false;
    header ("Location: $FF_redirectLoginSuccess");
    exit;
  }
  mysql_free_result($FF_rsUser);
  session_register("FF_login_failed");
  $FF_login_failed = true;
  header ("Location: $FF_redirectLoginFailed");
  exit;
}
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="form1" method="POST" action="<?php echo $FF_LoginAction?>">
<input name="username" type="text">
<input name="password" type="text">
</form>
</body>
</html>
Mark
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

EXACTLY
User avatar
aquila125
Forum Commoner
Posts: 96
Joined: Tue Dec 09, 2003 10:39 am
Location: Belgium

Post by aquila125 »

seems like DWMX is using the old PHP syntax.. if you have a new PHP engine, you'll need to turn on the reg_globals... (i think!)

you could change the code that dreamweaver creates since it's not that safe...

$HTTP_SERVER_VARS should become $_SERVER
$HTTP_POST_VARS should become $_POST
session_register("varname") should become $_SESSION['varname']

I believe DWMX2004 has the correct syntax
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

no way of passing vars then?
User avatar
aquila125
Forum Commoner
Posts: 96
Joined: Tue Dec 09, 2003 10:39 am
Location: Belgium

Post by aquila125 »

yes.. on this page you can access the vars like this:


just insert the code as Bech100 showed:

$username = $_POST['username'];
$_SESSION['username'] = $_POST['username'];
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

ok, it still didnt work

i replaced all the old tags with the new ones, (debugged in zend studio, everything was ok) and it still didnt retrieve the vars, can someone/anyone that has a clue as to why this is happening please tell me, i have a contract to complete asap and this is doing my head in, really cannot understand why it is doing this, it works perfectly if i turn register globals on but im not sure if the hosting company support it and i really would like to design it properly

Thanks
Post Reply