Jump to content

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) {

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.