Irresistable Posted November 1, 2009 Share Posted November 1, 2009 Fatal error: Call to undefined method Process::procRegister() in /home/jeanie/public_html/Newsletter Beta/process.php on line 11 <? include("include/session.php"); class Process { /* Class constructor */ function Process(){ global $session; /* User submitted registration form */ if(isset($_POST['subjoin'])){ $this->procRegister(); } function procRegister(){ global $session, $form; /* Registration attempt */ $retval = $session->register($_POST['email'], $_POST['user_code']); /* Registration Successful */ if($retval == 0){ $_SESSION['reguname'] = $_POST['email']; $_SESSION['regsuccess'] = true; header("Location: ".$session->referrer); } /* Error found with form */ else if($retval == 1){ $_SESSION['value_array'] = $_POST; $_SESSION['error_array'] = $form->getErrorArray(); header("Location: ".$session->referrer); } /* Registration attempt failed */ else if($retval == 2){ $_SESSION['reguname'] = $_POST['email']; $_SESSION['regsuccess'] = false; header("Location: ".$session->referrer); } } } }; /* Initialize process */ $process = new Process; ?> "function procRegister(){" is Line 11 Quote Link to comment https://forums.phpfreaks.com/topic/179859-solved-fatal-error-newsletter-script/ Share on other sites More sharing options...
Alex Posted November 1, 2009 Share Posted November 1, 2009 You're never closing your constructor. class Process { /* Class constructor */ function Process(){ global $session; /* User submitted registration form */ if(isset($_POST['subjoin'])){ $this->procRegister(); } } // Forgot this. Quote Link to comment https://forums.phpfreaks.com/topic/179859-solved-fatal-error-newsletter-script/#findComment-948823 Share on other sites More sharing options...
Irresistable Posted November 1, 2009 Author Share Posted November 1, 2009 Cheers. That fixed my problem, but the next problem is.. when I click "subscribe" on the main page, it loads the process.php page.. no errors, but it doesn't redirect back to the main page showing errors, or whatever it has to show. Quote Link to comment https://forums.phpfreaks.com/topic/179859-solved-fatal-error-newsletter-script/#findComment-948828 Share on other sites More sharing options...
Alex Posted November 1, 2009 Share Posted November 1, 2009 Add some debugging to your code so you can see what's going wrong. More specifically you might want to check to make sure $session->referrer contains what you want it to. Quote Link to comment https://forums.phpfreaks.com/topic/179859-solved-fatal-error-newsletter-script/#findComment-948832 Share on other sites More sharing options...
Irresistable Posted November 1, 2009 Author Share Posted November 1, 2009 Within session.php I never set var referrer. Thanks for your help. Another Fatal error - This is when I set in the right details subscription area. Fatal error: Call to undefined method MySQLDB::emailTaken() in /home/jeanie/public_html/Newsletter Beta/include/session.php on line 49 Line 49 - " else if($database->emailTaken($subemail)){" <?php include("database.php"); include("mailer.php"); include("form.php"); class Session { var $referrer; //Last recorded site page viewed /* Class constructor */ function Session(){ $this->time = time(); $this->startSession(); /* Set referrer page */ if(isset($_SESSION['url'])){ $this->referrer = $_SESSION['url']; }else{ $this->referrer = "/"; } /* Set current url */ $this->url = $_SESSION['url'] = $_SERVER['PHP_SELF']; } function startSession(){ global $database; //The database connection session_start(); //Tell PHP to start the session } function register($subemail, $subuser_code){ global $database, $form, $mailer; //The database, form and mailer object /* Email error checking */ $field = "email"; //Use field name for email if(!$subemail || strlen($subemail = trim($subemail)) == 0){ $form->setError($field, "*Email not entered "); } else{ /* Check if valid email address */ $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*" ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*" ."\.([a-z]{2,}){1}$"; if(!eregi($regex,$subemail)){ $form->setError($field, "*Email invalid "); $subemail = stripslashes($subemail); } else if($database->emailTaken($subemail)){ $form->setError($field, "*Email already been subscribed "); } } /* Captcha error chcking */ $field = "captcha"; //Use field name for gender if (strcmp(md5($subuser_code),$_SESSION['ckey'])){ $form->setError($field, "*Captcha image is incorrect"); } /* Errors exist, have user correct them */ if($form->num_errors > 0){ return 1; //Errors with form } /* No errors, add the new account to the database */ else{ $activ_code = rand(1000000,9999999); if($database->addNewUser($subemail, $activ_code)){ if(EMAIL_WELCOME){ $mailer->sendWelcome($subemail,$activ_code); } return 0; // New user added succesfully }else{ return 2; //Registration attempt failed } } } }; $session = new Session; /* Initialize form object */ $form = new Form; ?> Quote Link to comment https://forums.phpfreaks.com/topic/179859-solved-fatal-error-newsletter-script/#findComment-948833 Share on other sites More sharing options...
Alex Posted November 1, 2009 Share Posted November 1, 2009 I'd need to see the MYSQLDB Class. Quote Link to comment https://forums.phpfreaks.com/topic/179859-solved-fatal-error-newsletter-script/#findComment-948839 Share on other sites More sharing options...
Irresistable Posted November 1, 2009 Author Share Posted November 1, 2009 <?php include("constants.php"); class MySQLDB { var $connection; //The MySQL database connection /* Class constructor */ function MySQLDB(){ /* Make connection to database */ $this->connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die(mysql_error()); mysql_select_db(DB_NAME, $this->connection) or die(mysql_error()); } function addNewUser($email, $activ_code){ $email = mysql_real_escape_string($email); $activ_code = mysql_real_escape_string($activ_code); $time = date("F j, Y, g:i"); $q = "INSERT INTO ".TBL_USERS." VALUES ('$email', '$activ_code', '$time')"; return mysql_query($q, $this->connection); } function query($query){ return mysql_query($query, $this->connection); } }; /* Create database connection */ $database = new MySQLDB; ?> Quote Link to comment https://forums.phpfreaks.com/topic/179859-solved-fatal-error-newsletter-script/#findComment-948840 Share on other sites More sharing options...
Irresistable Posted November 1, 2009 Author Share Posted November 1, 2009 Thats the mysqlDB class by the way. ^^ Quote Link to comment https://forums.phpfreaks.com/topic/179859-solved-fatal-error-newsletter-script/#findComment-948848 Share on other sites More sharing options...
Alex Posted November 1, 2009 Share Posted November 1, 2009 Well isn't the problem clear then? It's exactly what the error message says, within the MySQLDB class there is no method named 'emailTaken'. Quote Link to comment https://forums.phpfreaks.com/topic/179859-solved-fatal-error-newsletter-script/#findComment-948851 Share on other sites More sharing options...
Irresistable Posted November 1, 2009 Author Share Posted November 1, 2009 Sorry, I didn't know. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/179859-solved-fatal-error-newsletter-script/#findComment-948887 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.