Jump to content


is there anything wrong with this?


3 replies to this topic

#1 Chris.

    Young Padawan

  • Members
  • Pip
  • 129 posts
  • Gender:Male

Posted 21 September 2006 - 10:06 PM

Does anyone see anything wrong with this register script? I keep getting the "A required field was left blank!". Here it is.

<?php
error_reporting(E_ALL ^ E_NOTICE);
ob_start();
// allows you to use cookies
include("settings/config.php");
include("settings/protection.php");
cleanall(); //SQL Injection Protection
if($logged[username]){
die("You are already registered as $logged[username], you can't register twice!");
} else {
//gets the config page
if ($_POST['register']) {
// the above line checks to see if the html form has been submitted
$username = $_POST['username'];
$password = $_POST['pass'];
$cpassword = $_POST['cpass'];
$email = $_POST['emai1'];
$webtitle = $_POST['webtitle'];
$weburl = $_POST['weburl'];
$aim = $_POST['aim'];
$msn = $_POST['msn'];
$location = $_POST['localtion'];
//the above lines set variables with the user submitted information
if($username==""|$password==""|$cpassword==""|$email=="") {
//checks to make sure no fields were left blank
echo "A required field was left blank!";
} else {
//none were left blank!  We continue...
if($password != $cpassword) {
// the passwords are not the same!  
echo "Passwords do not match";
}else{
// the passwords are the same!  we continue...
$password = md5($password);
// encrypts the password
$checkname = mysql_query("SELECT username FROM users WHERE username='$username'");
$checkname= mysql_num_rows($checkname);
$checkemail = mysql_query("SELECT email FROM users WHERE email='$email'");
$checkemail = mysql_num_rows($checkemail);
if ($checkemail>0|$checkname>0) {
// oops...someone has already registered with that username or email!
echo "The username or email is already in use";
}else{
// noone is using that email or username!  We continue...
$username = htmlspecialchars($username);
$password = htmlspecialchars($password);
$email = htmlspecialchars($email);
// the above lines make it so that there is no html in the user submitted information.
//Everything seems good, lets insert.
$query = mysql_query("INSERT INTO users (username, password, email, msn, aim, location, webtitle, weburl) VALUES('$username','$password','$email','$msn', '$aim', '$location', '$webtitle', '$weburl')");
// inserts the information into the database.
echo "You have successfully registered! <a href='login.php'>Login?</a>";
}
}
}
} else {
?>
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
.style2 {color: #000000}
.style6 {color: #000000; font-weight: bold; }
-->
</style>
<center>
<form action="" method="POST">
<table width="350"> 
<td width="172">
  <tr>
	<td width="172"><span class="style6">Required Information</span></td>
	<td width="10"><span class="style1"></span></td>
	<td width="155"></td>
  </tr>
  <tr>
	<td width="172"><span class="style2">Username*</span></td>
	<td width="10"><span class="style2">:</span></td>
	<td width="155"><input name="username" type="text" id="username" size="25" maxlength="25" /></td>
  </tr>
  <tr>
	<td >Password*</td>
	<td >:</td>
	<td ><input name="pass" type="password" id="pass" size="25" maxlength="25" /></td>
  </tr>
  <tr>
	<td >Confirm Password*</td>
	<td >:</td>
	<td ><input name="cpass" type="password" id="cpass" size="25" maxlength="25" /></td>
  </tr>
  <tr>
	<td >Email*</td>
	<td >:</td>
	<td ><input name="email" type="text" id="email" size="25" maxlength="25" /></td>
  </tr>
  <tr>
	<td ><span class="style6">Optional Information</span> </td>
	<td >&nbsp;</td>
	<td >&nbsp;</td>
  </tr>
  <tr>
	<td >Location</td>
	<td>:</td>
	<td ><input name="location" type="text" id="location" size="25" maxlength="25" /></td>
  </tr>
  <tr>
	<td >MSN Messenger </td>
	<td>:</td>
	<td ><input name="msn" type="text" id="msn" size="25" maxlength="25" /></td>
  </tr>
  <tr>
	<td >AIM Messenger </td>
	<td>:</td>
	<td ><input name="aim" type="text" id="aim" size="25" maxlength="25" /></td>
  </tr>
  <tr>
	<td >Website Title </td>
	<td>:</td>
	<td ><input name="webtitle" type="text" id="webtitle" size="25" maxlength="25" /></td>
  </tr>
  <tr>
	<td >Website URL</td>
	<td>:</td>
	<td ><input name="weburl" type="text" id="weburl" size="25" maxlength="25" /></td>
  </tr>
  <tr>
	<td><a href="#">Forgot password?</a></td>
	<td></td>
	<td><input name="register" type=submit id="register" value="Register"></td>
  </tr>
</td>
</table>
</form>
</center>
<?php
}
}
?>

Thanks

#2 Rory

    Jedi In Training

  • Members
  • PipPip
  • 378 posts
  • Gender:Male
  • Location:Hastings, Hawkes bay, New Zealand
  • Interests:Php, Html, Css, Javascript, ASP.NET, Photoshop, soccer, rigby, cricket, viticulture, Ruby#, C#, AJAX.

Posted 21 September 2006 - 10:32 PM

Typing error:
$email = $_POST['emai1'];

That line should say:
$email = $_POST['email'];

You accidentally used a 1 instead of an l.

#3 Av-

    I Feel Left Out

  • Members
  • PipPipPipPip
  • 1,971 posts
  • Gender:Male
  • Location:10 ft. below sea level

Posted 22 September 2006 - 05:28 AM

the consequences of getting used to typing 1337 :D

#4 Chris.

    Young Padawan

  • Members
  • Pip
  • 129 posts
  • Gender:Male

Posted 22 September 2006 - 02:16 PM

:P Thanks I guess I overlooked that





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users