Jump to content

garry27

Members
  • Posts

    161
  • Joined

  • Last visited

    Never

Everything posted by garry27

  1. why isn't it working dammit?  :(
  2. i can log on now afer i deleted the stupid variable after db connection on login() but i'm still getting: Warning: Missing argument 2 for login() in /home/unn_p921847/public_html/common.php on line 38 Warning: Missing argument 2 for login() in /home/unn_p921847/public_html/common.php on line 38 Warning: Missing argument 2 for login() in /home/unn_p921847/public_html/common.php on line 38 : [code] function login($email, $pwd)              //line 38 {         $conn = db_connect();         $sql = "select * from All_Users where userEmail='$email' and userPassword='$pwd'";            $result=$conn->query($sql);           if ($result->num_rows >0 ) {   $sql = "select Member.accType from Member                   Where Member.userEmail='$email'";   $account_type = $conn->query($sql);     }         return true; }[/code] ???
  3. i've been stuck on this for well over an hour now. any help would me much appreciated. [code] function login($email, $pwd) {         $conn = db_connect($account_type);         $sql = "select * from All_Users where userEmail='$email' and userPassword='$pwd'";            $result=$conn->query($sql);           if ($result->num_rows >0 ) {   $sql = "select Member.accType from Member                                     Where Member.userEmail='$email'"; $account_type = $conn->query($sql); }         return $account_type ;[/code]         [code]<?php //Initiates php script containing functions all common functions session_start(); require_once('common.php'); $dbconnect = db_connect(); //outputs header info to brower with the following title echo xhtmlheader('Personal Account Registration Form');   //outputs the main navigation bar to the browser echo topnav_pa(); if (isset($_POST['email']) && isset ($_POST['pwd'])) {         //if the user has just tried to log in         $email = $_POST['email'];         $pwd = $_POST['pwd'];                   if(login($_POST)== 'B') { $_SESSION['valid_user'] = $email; $member_homepage = 'pa_home.php'; } if(login($_POST)== 'P') { $_SESSION['valid_user'] = $email; $member_homepage = 'ba_home.php'; }         if(!login($_POST)) echo 'membership not recognised'; } ?> <!-- main body of page --> <div id="main">   <h1>My Pub Crawl Planner</h1>   <?php   if (isset($_SESSION['valid_user']))   {     echo '<h1> You are logged in as: '.$_SESSION['valid_user'].' </h1><br />'; echo "<a href=$member_homepage>go to home page</a>"; echo "<a class='logout' href='logout.php'>Log out</a>";   }   else   {     if (isset($email))     {       // if they've tried and failed to log in       echo 'Could not log you in.<br />';     }     else     {       // they have not tried to log in yet or have logged out       echo 'You are not logged in.<br />';     }   } ?>         <p>Member Login </p> <?php echo show_loginfrm(); ?>[/code]<!-- main body of page --> <div id="main">   <h1>My Pub Crawl Planner</h1>   [code] <?php   if (isset($_SESSION['valid_user']))   {     echo '<h1> You are logged in as: '.$_SESSION['valid_user'].' </h1><br />'; echo "<a href=$member_homepage>go to home page</a>"; echo "<a class='logout' href='logout.php'>Log out</a>";   }   else   {     if (isset($email))     {       // if they've tried and failed to log in       echo 'Could not log you in.<br />';     }     else     {       // they have not tried to log in yet or have logged out       echo 'You are not logged in.<br />';     }   } ?>         <p>Member Login </p> <?php echo show_loginfrm(); ?> [/code]
  4. i've already defined the function login:             [code]...         $sql = "select Member.accType from Member                   Where Member.userEmail='$email";             $account_type = $conn->query($sql);         return $account_type;         } [/code] now i'm trying to call the value of $account_type using post: [code]                if(login($_POST)== 'P') { $_SESSION['valid_user'] = $email; $member_homepage = 'pa_home.php'; } if(login($_POST)== 'B') { $_SESSION['valid_user'] = $email; $member_homepage = 'ba_home.php'; }                           if(!login($_POST)) echo 'membership not recognised';[/code]
  5. hi all, how do you return a value from inside a function which you can use when you call it? i.e. in the following code, i'm trying to return the value of $account_type to the login function:                         [code]if(login($_POST)== 'P') { $_SESSION['valid_user'] = $email; $member_homepage = 'pa_home.php'; } if(login($_POST)== 'B') { $_SESSION['valid_user'] = $email; $member_homepage = 'ba_home.php'; }                           if(!login($_POST)) echo 'membership not recognised';[/code] TIA Garry        
  6. it doesn't work when i use the long hand way of connecting to db- i get: Fatal error: Call to a member function query() on a non-object in /home/unn_p921847/public_html/pa_home.php on line 59 ...but when i use the short hand method which i copied from a book, it seems to connect ok (or at least doesn't spit back any errors) but then the i get no results with the mysql. im fed up of this. i've spent over a day trying to solve this. i never had a problem connecting before when i was using request. ever since i'm having to use sessions to pass on data, i'm having problems.
  7. ok so i'm trying to get the following code to verifiy $email and $pwd as part of a login process: <?php session_start(); // Initiates php script containing functions   require_once('common.php');   require_once('user_auth_fs.php'); $email = $_GET['email']; $pwd = $_GET['pwd']; // turn off run-time error notices $old_level = error_reporting(E_ALL & ~E_NOTICE); if ($email && $pwd) // they have just tried logging in {   try   {     login($email, $pwd);     // if they are in the database register the user id     $_SESSION['valid_user'] = $email;   }   catch(Exception $e)   {     // unsuccessful login     echo  'You could not be logged in. You must be logged in to view this page.';     exit;   }      } ?> but i'm not getting anything outputted to my $sql variable. the sql doesn't seem to be working but the db connection is fine. <?php    //user_auth_fs.php      function login ($email, $pwd)   {   // check username and password with db   // if yes, return true   // else throw exception   // turn off run-time error notices   $old_level = error_reporting(E_ALL & ~E_NOTICE);     // connect to db   $conn = db_connect();     $sql = $conn->query("SELECT * from members;");   echo $sql; ?> please can someone tell me how to fix this?  
  8. why do i get undefined index variable errors when i run the following script using register_pa() shown further down the page? ??? here's an example of the url output: ........... register_pa.php?email=garry@yahoo.co.uk&pwd=secret&forename=Garry&pwd2=secret&surname=McCabe&gender=m&ta_terms=%09++++&pa_regfrmbtn=Register and the errors: Notice: Undefined index: email in /home/unn_p921847/public_html/register_pa.php on line 14 Notice: Undefined index: pwd in /home/unn_p921847/public_html/register_pa.php on line 15 Notice: Undefined index: forename in /home/unn_p921847/public_html/register_pa.php on line 16 Notice: Undefined index: pwd2 in /home/unn_p921847/public_html/register_pa.php on line 17 Notice: Undefined index: surname in /home/unn_p921847/public_html/register_pa.php on line 18 Notice: Undefined index: gender in /home/unn_p921847/public_html/register_pa.php on line 19 The password must be at least 6 characters long- please go back and try again. <?php    /*****open a session and open function scripts  *************************/   session_start();   require_once('common.php');        ///////accesses db_connect()   require_once('register_fs.php');    ///////accesses register_pa()      //outputs header info to brower with the following title   echo xhtmlheader('Error');   //outputs the main navigation bar to the browser   //echo topnav_pa();   $email = $_POST['email'];   $pwd = $_POST['pwd'];   $forename = $_POST['forename'];   $pwd2 = $_POST['pwd2'];   $surname = $_POST['surname'];   $gender = $_POST['gender']; /*  $agree_terms = $_GET['agree_terms']; */   if (!get_magic_quotes_gpc())     {   $email = addslashes($email);   $pwd = addslashes($pwd);   $forename = addslashes($forename);   $surname = addslashes($surname);   $gender = addslashes($gender); }   echo $email;   // turn off run-time error notices   $old_level = error_reporting(E_ALL & ~E_NOTICE);       try   {     //checks if all the fields in the form are filled out     if (!filled_out($_POST))     {     throw new Exception("You have not filled the form out correctly"                         ."- please go back and try again.");     }     if ($pwd != $pwd2)     {     throw new Exception("The passwords you entered do not match"                         ."- please go back and try again.");     }     if (strlen($pwd)<6 || strlen($pwd) >16)     {     throw new Exception("The password must be at least 6 characters long"                         ."- please go back and try again."); }       /****** attempt to register ****************************************************/       register_pa ($email, $pwd, $forename, $surname, $gender);     $_SESSION['valid_user'] = $email;       echo 'your registration was succesful';     echo "<br/><br/><a href='pau_home.php'>Go to members page</a>"; echo xhtmlheader('Registration Completed');       }   catch (Exception $e)   {     echo $e->getMessage();     exit;   }   ?> <?php function register_pa ($email, $pwd, $forename, $surname, $gender) {   //connect to database   $conn = db_connect();     try   {     //check username is unique     $result = $conn->query("select * from Authourised_User where userEmail='$email'");          if(!$result)     {     throw new Exception('could not execute query') ;     }       if($result->num_rows>0)     {     throw new Exception ('That e-mail address is already registered with us'                     .'- please go back and choose a different one.');     }           //if ok, put in db     $result = $conn->query("INSERT into Authourised_User values                             ('$email','$pwd)");       if (!$result)     {     throw new Exception ('Could not register you in database '                       .'- please try again later.');     }   }   catch (Exception $e)   {     echo $e->getMessage(); return true;     exit;   }  } much TIA
  9. hiya, thanks for replying! i've commented out the exception error statements on the functions page and now I get undefined index errors when i submit the register form: http://www.nl-webspace.co.uk/~unn_p921847/register_pa.php?email=garry@yahoo.com&pwd=asdfgh&forename=garry&pwd2=asdfgh&surname=mccabe&gender=m&ta_terms=%09++++&pa_regfrmbtn=Register ????????
  10. hi, i'm new to php and this forum so i hope that somone can help me. i've been stuck on this problem for all day. i'm trying to create a registration feature for a website which i'm practically copying most of it from a book but the script won't work. i get various errors at run-time. here's my script which is supposed to add a new user (using a function register() available in register_fs.php shown further down the page) to my mysql table which is already created. [code] <?php  //register_pa.php   /*****open function scripts and open a session *************************/   require_once('common.php');   require_once('register_fs.php');   session_start();   //outputs header info to brower with the following title   echo xhtmlheader('Error');   //outputs the main navigation bar to the browser   //echo topnav_pa();   $email = $_GET['email'];   $pwd = $_GET['pwd'];   $forename = $_GET['forename'];   $pwd2 = $_GET['pwd2'];   $surname = $_GET['surname'];   $gender = $_GET['gender']; /*  $agree_terms = $_GET['agree_terms']; */   if (!get_magic_quotes_gpc())     {   $email = addslashes($email);   $pwd = addslashes($pwd);   $forename = addslashes($forename);   $surname = addslashes($surname);   $gender = addslashes($gender); }   // turn off run-time error notices   $old_level = error_reporting(E_ALL & ~E_NOTICE);     try   {     //checks if all the fields in the form are filled out     if (!filled_out($_POST))     {     throw new Exception("You have not filled the form out correctly"                         ."- please go back and try again.");     }     if ($pwd != $pwd2)     {     throw new Exception("The passwords you entered do not match"                         ."- please go back and try again.");     }     if (strlen($pwd)<6 || strlen($pwd) >16)     {     throw new Exception("The password must be at least 6 characters long"                         ."- please go back and try again."); }       /****** attempt to register ****************************************************/       register_pa ($email, $pwd, $forename, $surname, $gender);     $_SESSION['valid_user'] = $email;       echo 'your registration was succesful';     echo "<br/><br/><a href='pau_home.php'>Go to members page</a>"; echo xhtmlheader('Registration Completed');     }   catch (Exception $e)   {     echo $e->getMessage();     exit;   }     // revert back to default error report values   error_reporting(£old_level); ?> [/code] here's my register_fs script: [code] <?php //register_ps.php function filled_out($form_vars) {   // test that each variable has a value   foreach ($form_vars as $key => $value)   {     if (!isset($key) || ($value == ''))         return false;   }   return true; } function register_pa ($email, $pwd, $forename, $surname, $gender) {   //connect to database   $conn = db_connect();     //check username is unique   $result = $conn->query("select * from Authourised_User where userEmail='$email'");   if(!$result)     throw new Exception('could not execute query');     if($result->num_rows>0)     throw new Exception ('That e-mail address is already registered with us'                     .'- please go back and choose a different one.');   //if ok, put in db   $result = $conn->query("INSERT into Authourised_User values                           ('$email', ('$pwd')   set userPassword='$pwd'");     if (!$result)     throw new Exception ('Could not register you in database '                     .'- please try again later.');   return true; } ?> [/code]
×
×
  • 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.