Jump to content

Problem's with my register script


nathanmaxsonadil

Recommended Posts

my login script wont output the error

 

Here's the code

<?php
$title = 'Swap Invites - Register';
include 'header.php';
include('./config.php');

$divs = '<div style="clear: both;"> </div></div>';
function forum() {
echo "<div id='content'>
<div id='columnA'><h2>Register</h2><br/>";
if(isset($error)) {
echo $error;
}
echo "<br/><form method='post'>
username:<br/>
<input type='text' name='username' />
<br />
email:<br/>
<input type='text' name='email' />
<br />
password:<br/><input type='password' name='password' />
<br/>
retype password:<br/><input type='password' name='password2' />
<br/>
<input type='submit' name='submit' value='Submit' />

</form></div> ";
}


if(empty($_POST)) {
forum();
include 'sidebar.php';
echo $divs;
include 'footer.php';
exit();
}
if(isset($_POST[submit])) {
if(strlen($_POST[username]) > '16') {
$error = "you username is too long! it has to be less than 16 chachters!";
forum();
include 'sidebar.php';
echo $divs;
include 'footer.php';
exit();
}//and so on....

When you enter too long a username it is supposed to echo a error telling you have to have a shorter username however it just display's the normal thing :(

Link to comment
https://forums.phpfreaks.com/topic/65337-problems-with-my-register-script/
Share on other sites

Integers are NOT supposed to be surrounded by quotes (making them strings).

 

if(strlen($_POST[username]) > '16') {

 

Should be....

 

if(strlen($_POST[username]) > 16) {

 

Also note that non numeric array indexes need quotes, so the line really ought be....

 

if(strlen($_POST['username']) > 16) {

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.