Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/179859-solved-fatal-error-newsletter-script/
Share on other sites

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.

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.

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;
?>

<?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;

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.