Please help with my code

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

Post Reply
gimpact
Forum Commoner
Posts: 65
Joined: Tue Jun 16, 2009 11:08 pm

Please help with my code

Post by gimpact »

Hello,
Please help me with my code, When ever i run this code I am getting an error: " Parse error: syntax error, unexpected '{' in /home/content/s/d/g/123/html/websites/x/candidate/secure/register/Register.php on line 19 "

I code in netbeans and run my files directly on the server.

Code: Select all

<?php
include ("DBConnect.php");
class Register{
     function _construct(){
        if (ISSET($_POST['SUBMIT'])){
            $firstname = mysql_real_escape_string(stripslashes($_REQUEST['firstname']));
            $lastname = mysql_real_escape_string(stripslashes($_REQUEST['lastname']));
            $email1 = mysql_real_escape_string(stripslashes($_REQUEST['email1']));
            $email2 = mysql_real_escape_string(stripslashes($_REQUEST['email2']));
            $password = mysql_real_escape_string(stripslashes($_REQUEST['password1']));
            $password2 = mysql_real_escape_string(stripslashes($_REQUEST['password2']));
 
            // Check if email and password match
            if($email1 != $email2){
                header("Location:http://www.x.com/candidate/register/index2.php?ID=email");
            }else if($password != $password2){
                header("Location:http://www.x.com/candidate/register/index2.php?ID=password");
            }else{
                try{
                    // Generate random number
                    $random = (rand()%10000000);
                    // Send mail
                    sendmail($email1,$random);
                        if (PEAR::isError($mail)) {
                            echo("<p>" . $mail->getMessage() . "</p>");
                        }else {
                            // Open database connection and save
                           // $dbconnection = new DBConnect();
                           // $dbconnection -> DBConnect();
                           // $sql = "INSERT INTO user_account WHERE email = $email1";
                            echo("<p>Message successfully sent!</p>");
                        }
                }catch(Exception $e){
                    $e->getMessage();
                    $e->getCode();
                }
            }
        }else{
            header("Location:http://www.x.com/home");
        }
    }// end of _construct()
 
    private function sendmail($email,$activationpass){
        $from = "x.com <no-reply@x.com>";
        $to = $email;
        $subject = "Activate your account";
        $body = "Hi".$email.", /n/n Please activate your x account
            by clicking the link bellow/n/n
            http://www.x.com/account/activate.php?e ... vationpass";
 
        $host = "relay-hosting.ddl.net";
        $username = "info@x.com";
        $password = "abc";
        $headers = array ('From' => $from,
        'To' => $to,
        'Subject' => $subject);
        $smtp = Mail::factory('smtp',
        array ('host' => $host,
        'auth' => true,
        'username' => $username,
        'password' => $password));
        $mail = $smtp->send($to, $headers, $body);
        } //End of email function
 
}
?>
Thank you,
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Please help with my code

Post by jackpf »

I don't get an error.
gimpact
Forum Commoner
Posts: 65
Joined: Tue Jun 16, 2009 11:08 pm

Re: Please help with my code

Post by gimpact »

8O
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Please help with my code

Post by jackpf »

Well, I obviously get include errors cause I don't have the same files as you, but no parse errors.
Post Reply