Jump to content

Starting a login script, have an odd problem.. and allowing certain characters


corrupshun

Recommended Posts

So what i have so far on the login script checks to see if the information posted is even set, if it's empty, and if the password is the password confrimation.

It's still very basic and has no login characteristics. I checked over the code for an hour at school (study hall) (irrelevant :P) and cannot find the problem. (the code is below)

<?php
if(isset($_POST['username']) && isset($_POST['password']) && isset($POST['password2']) && isset($_POST['email'])) {
if(!empty($_POST['username']) && !empty($_POST['password']) && !empty($POST['password2']) && !empty($_POST['email'])) {
if($_POST['password']==$_POST['password2']) {
//&& (strlen($_POST['username'])<=20){
$password = md5('$_POST[password]');
$date = date('F d, Y');
$username = $_POST['username'];
$email = $_POST['email'];
echo "$username $email $password $date";
echo strlen("$username");
}
else {
echo "passwords do not match";
}
}
else {
echo "One or more fields are empty.";
}
}
else {
if(!isset($_POST['submit'])) {
echo "Signup Here";
}
}
?>
<html>
<form name="register" action="register.php" method="POST">
Username<input type="text" name="username" /><br />
Password<input type="password" name="password" /><br />
Confirm Password<input type="password" name="password2" /><br />
Email-Address<input type="text" name="email" /><br />
<input type="submit" value="Register!" name="submit" />
</form>
</html>

 

 

My second question is what I would like to add soon.

I looked over the filter_var() function on w3schools and didn't see anything for what i wanted.

for the username I only want to allow the following:

(A-Z),(a-z),(0-9),dashes, underscores, periods, and spaces. How would I check to see that?

I would do the regex stuff, which is probably the way to go, but i have NO clue how do use it :)

Link to comment
Share on other sites

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.