Jump to content

Easy class question


Perad

Recommended Posts

Its been a while since I have used classes and I am obviously doing something wrong. When I submit the form nothing is happening. Could someone tell me what I need to do to actually make something happen.

 

Head of register.php

<?php 
include 'functions.php';	
if ($_POST['register']) {
	$register = new Register;
	$register->SQL($_POST['user'], $_POST['pass'], $POST['confpass'], $POST_['email']);
}

?>

 

register.php content

 <?php
        	if ($register->error || $register->message) {
            	print $register->error;
			print $register->message;
		} else {
	?>
        	<form name="register" action="register.php" method="post">
            	Username:<input type="text" name="user" class="login" value="" maxlength="20">
                Password:<input type="text" name="pass" class="login" value="" maxlength="20">
                Confirm Password:<input type="text" name="confpass" class="login" value="" maxlength="20">
                E-Mail:<input type="text" name="email" class="login" value="" maxlength="40">
                <input type="submit" value="Register" name="Register" />  
            </form>
        <?php 
		}
	?>

 

functions.php

 

<?php

class Register {
public $message;
public $error;

public function SQL($user, $pass, $confpass, $email) {
	echo "ha";
	$clean_user = $this->cleanString($user);
	$clean_pass = $this->cleanString($pass);
	$clean_confpass = $this->cleanString($confpass);
	$clean_email = $this->cleanString($email);

	if ($clean_pass == $clean_confpass) {
		$sql = "INSERT INTO members (username, password, email, join) VALUES ('$clean_user', '$clean_pass', '$clean_email', NOW())";
		$result = mysql_query($sql) or die(mysql_error());
		if ($result) {
			$this->message = "Congrats, you have successfully registered";
		} else {
			$this->error = "There has been an error, please try again later";
		}
	} else {
		$this->error = "Error: Your passwords do not match";
	}
}

private function cleanString($string, $length) {
	$string = trim($string);
	$string = stripslashes($string);
	$string = strip_tags($string);
	$string = substr($string, 0, $length);
	return $string;
}

}

 

Any help with this is every much appreciated

Link to comment
Share on other sites

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.