Jump to content

trying to use strlen to get length of username & pw & email ( Error )


Mythic Fr0st

Recommended Posts

I get a parse errror

Parse error: parse error in c:\program files\easyphp1-8\www\test\signup.php on line 57

im trying to get the string length of the text boxes, username, password, password confirm, and same for email,

I want it to stop if they dont match, I think im using strlen wrong though...
[code]
<input type='submit' value='Signup' onsubmit='DM()'>[/code]


[code]<?php
function DM()
{
$i=(!strlen('user'))
$pw[1]=(!strlen('pw1'))
$pw[2]=(!strlen('pw2'))
$em[1]=(!strlen('email1')
$em[2]=(!strlen('email2')
}
?>[/code]

im trying to set (!strlen('NameOfTXTbox')) to a variable called $i, but I get error :/, neeed this fixed badly, Can anyone help?
[code]
<?
function checkLength($test, $minLength)
{
if (strlen($test) < $minLength)
{
return false;
}
else
{
return true;
}
}

// Use it like this

if (!checkLength($_POST['user'], 4))
{
echo "Username Not Long Enough!";
}
?>
[/code]
Okay, your code works, but I need it to stop the browser immediately from continuing
[code]function checkLength($user, $minLength)
{
      if (strlen($user) < $minLength)
      {
              return false;
      }
      else
      {
              return true;
      }
}

if (!checkLength($_POST['user'], 4))
{
        echo 'Your username requires atleast 5 characters';
}
?>[/code]

what code do I use for that?
SO exit() will just basically, pause the browser and leave it on the same page?

and redirect thing, will take it back to the same page, with a new error... hmm, Redirect sounds good!

and, whenever I click refresh, if username & password boxes, arent atleast 5 chars, or passwords & e-mails dont match, it displays it, anyway to make it redirect back to the browser, and display them then?
redirect code: replace the echo with this...
[code]
header("location: http://something.com/signuppage.php?error=tooshort");
[/code]

on signuppage.php

[code]
if ($_POST['error'] == tooshort)
{
     echo "The username you entered was too short";
}
[/code]

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.