I made a registration script my problem is getting the errors to post in the div area.

here is a picture:
http://screencast.com/t/OTcwNWMxN2Qt

<head>
    <LINK href="css.css" rel="stylesheet" type="text/css">
	<title>Registration</title>
	</head>
<div class="roundcont">
   <div class="roundtop">
	 <img src="/images/tl.gif" alt="" 
	 width="15" height="15" class="corner" 
	 style="display: none" />

	<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">

   <table class="table">
   <th>Registration</th>
   <tr>
		<td class="input-align">
		Username:<input type="text" name="username" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" size="30" maxlength="10" />
		</td>
   
   </tr>
   <tr>
		<td class="input-align">
			Password: <input class="c1" type="password" name="password">
		</td>	
   </tr>
   <tr>
		<td class="input-align">
			Password Confirmation: <input class="c1" type="password" name="password_confirm">
		</td>	
   </tr>
   <tr>
		<td class="input-align">
			Email Address: <input type="text" name="email" size="30" maxlength="30" value="<?php if(isset($_POST['email'])) echo $_POST['email']; ?>" />
		</td>	
   </tr>
   <!--<tr>
		<td class="input-align">
			Birth Date:  
	
   </tr>-->
		<tr>
		<td class="input-align">
		 <br><input align="center" class="reg" type="submit" value="Register!">
		 	<input type="hidden" name="submitted" value="TRUE" />
		</td>	
   </tr>
   
   
   </table>
   </form>
   </div>
  <script language="javascript">
document.forms[0].onsubmit = function() {
  if(this.elements['password'].value != this.elements['password_confirm'].value) {
    alert('Passwords do not match');
    return false;
  }

  return true;
}


</script>
   
	
	
  
   <div class="roundbottom">
	 <img src="/images/bl.gif" alt="" 
	 width="15" height="15" class="corner" 
	 style="display: none" />
   </div>
</div>
	

<?php
error_reporting(E_ALL ^ E_NOTICE); 
$username = $_REQUEST['username'];
$password = $_REQUEST['password'];
$email = $_REQUEST['email'];
$password_conf = $_REQUEST['password_confirm'];
$error = 0;
$unamecheck = mysql_query("SELECT * FROM users WHERE (username='$username')");
$spassword = md5($_REQUEST['password']);

// checks
if($_SERVER['REQUEST_METHOD']=="POST"){


if (mysql_num_rows($unamecheck) > 0) { 
		$error ++;
		echo "<p>The selected username has already been taken</p>";

} 

if(!$username){
	$error ++;
	echo "<p>You have not selected a username<br></p>";
}

if(!$password){
	$error ++;
	echo "<p>You have not entered a valid password</p>";

}
if(!$password_conf){
	$error ++;
	echo "<p>Please confirm your password.</p>";
	

}
if (!$email){
	
	$error ++;
	echo "<p>Please enter a valid email</p>";

}

if(strlen($password) < 5){
		$error ++;
		echo "<p>Your passwords must be 5 characters or more.</p>";
}


if(!$error){
	
	mysql_query ("INSERT INTO users (username, password, email) VALUES ('$username','$spassword','$email')");
	echo "You have been registered!";
	
	
}
else{
			echo "<p class=register>You have not been registered due to an error<p>";
	}
}
echo $error;

?>

This is the CSS

.roundcont {
	width: 500px;
	background-color: #f90;
	color: #fff;
}

.roundcont p {
	margin: 0 10px;
}

.roundtop { 
	background: url(/images/tr.gif) no-repeat top right; 
}

.roundbottom {
	background: url(/images/br.gif) no-repeat top right; 
}

img.corner {
   width: 15px;
   height: 15px;
   border: none;
   display:block  !important;
}

input {
  width : 190px;
  border : 1px;
  margin-right:110;

}

.reg{
	width : 100px;
	
}

.input-align{

	text-align: right;
}

p{
	font-family:Geneva;
	font-style:bold;
	font-size: 15px;
	font-weight:bold;
	color:red;

}



.register{
	color:blue;

}

Recommended Answers

All 3 Replies

So? Whats the error?
I don't think there are mediums on that forum...

So? Whats the error?
I don't think there are mediums on that forum...

What i meant was getting the erros (Username taken, Please enter an email, etc...) to appear in the orange area rather than under it

Thats actually not a php question.. but anyway... place your php code BEFORE the last "</div>"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.