How to code for a PHP user login with Oracle SQL? -
ok let me start off saying i'm pretty noob still php. i'm trying design user registration , login system queries user data oracle sql database, , tutorials helpful me mysql. wondering if had time me php coding working.
any @ appreciated.
edit: sorry forgot mention, i'm trying login page sets cookie keep users session until logout. have tried few different variations , none of them work ever. need work registration page have below.
my code user registration @ moment, of i'm sure pretty amateur is:
<?php /* set oracle user login , password info */ $dbuser = "xxxxxxx"; /* login */ $dbpass = "xxxxxx"; /* password */ $db = "xxxxx"; $connect = ocilogon($dbuser, $dbpass, $db); $salt = "plants"; if (!$connect) { echo "an error occurred connecting database"; exit; } // max id in plants table , allocate $id+1 new record $max_id_stmt = "select max(id) register_table"; // check sql statement errors , if errors report them $stmt = ociparse($connect, $max_id_stmt); if(!$stmt) { echo "an error occurred in parsing sql string.\n"; exit; } ociexecute($stmt); $id =0; if(ocifetch($stmt)) { $id= ociresult($stmt,1); //return data column 1 }else { echo "an error occurred in retrieving book id.\n"; exit; } $id++; // extract form data $username=$_request['username']; $password=$_request['password']; $email=$_request['email']; $phone=$_request['phone']; $address=$_request['address']; global $salt; // create sql statement add data. note: field value should single quoted '' if varchar2 type. $sql = "insert register_table values ($id, '$username', '$password', '$email', '$address', '$phone')"; $password = md5($salt.$password); // add data database new record $stmt = ociparse($connect, $sql); if(!$stmt) { echo "an error occurred in parsing sql string.\n"; exit; } ociexecute($stmt); echo ("<p>your registration has been successful!</p> <p>user id: $id</p> <p>username: $username</p> <p>phone: $phone</p> <p>address: $address</p> </p>") ?> thank you!
thank clarifying problem. think perhaps confusing php's $_request variables $_session variables. you'll need establish new session in order maintain user's session state, in turn (by default, anyway) sets cookie. can establish new session using standard php code either using session_start() or configuring php establish new session automatically.
of course, doing doesn't marry current user registration data you're passing database via above code; associating generated session id user data. suggest taking @ this page of php documentation quick primer.
Comments
Post a Comment