Need a few handy dandy tips :P

Alright, so I have a code:

-If you don’t mind glancing through it , I am having problems in checking if email is already used. The script is already able to check if it’s valid (like @blabla.com, but it 's not able to check my database to see if it’s already in use. I tried a few tricks up my sleeves none of em worked and I’m out :confused::confused::confused:)

  • I am trying to get recaptcha in, but it’s impossible to have a form inside a form. How could I get recaptcha into this thing. Code is here. Well what I am basically trying to do is what it’s doing when you post a topic in here. There’s a form, then a recaptcha you have to enter in, then post.

http://code.google.com/apis/recaptcha/docs/display.html#Standard

[php] <?php
// Connects to your Database

mysql_connect(“localhost”, “-----”, “----”) or die(mysql_error());

mysql_select_db("------------r") or die(mysql_error());

//This code runs if the form has been submitted

if (isset($_POST[‘submit’])) {

//This makes sure they did not leave any fields blank

if (!$_POST[‘username’] | !$_POST[‘pass’] | !$_POST[‘pass2’] | !$_POST[‘email’] ) {

	die('You did not complete all of the required fields.<a href="javascript: history.go(-1)">Back.</a>');

}

//check if email is in use

// checks if the username is in use

if (!get_magic_quotes_gpc()) {

	$_POST['username'] = addslashes($_POST['username']);

}

$usercheck = $_POST[‘username’];

$check = mysql_query(“SELECT username FROM users WHERE username = ‘$usercheck’”)

or die(mysql_error());

$check2 = mysql_num_rows($check);

//if the name exists it gives an error

if ($check2 != 0) {

	die('Sorry, the username '.$_POST['username'].' is already in use.<a href="javascript: history.go(-1)">Back.</a>');

			}

// this makes sure both passwords entered match

if ($_POST['pass'] != $_POST['pass2']) {

	die('Your passwords did not match.<a href="javascript: history.go(-1)">Back.</a> ');

}



// here we encrypt the password and add slashes if needed

$_POST['pass'] = md5($_POST['pass']);

if (!get_magic_quotes_gpc()) {

	$_POST['pass'] = addslashes($_POST['pass']);

	$_POST['username'] = addslashes($_POST['username']);

	$_POST['email'] = addslashes($_POST['email']);
	
	
		}

// now we insert it into the database

$insert = "INSERT INTO users (username, password, email)

		VALUES ('".$_POST['username']."', '".$_POST['pass']."', '".$_POST['email']."')";

$add_member = mysql_query($insert);

// redirect
echo(“”);

?>
<?php } else { ?>
<script type="text/javascript">

var emailfilter=/^\w+[+.\w-]@([\w-]+.)\w+[\w-]*.([a-z]{2,4}|\d+)$/i

function checkmail(e){
var returnval=emailfilter.test(e.value)
if (returnval==false){
alert(“Please enter a valid email address.”)
e.select()
}
return returnval
}

Email:
Username:
Password:
Confirm Password:

By clicking the button below you agree to the terms of service.

<?php } ?>

[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service