|
|
|
|
Thread title: Need some more help, few PHP things. |
|
|
|
|
|
Thread tools
Search this thread
Display Modes
|
|
11-23-2006, 07:16 AM
|
#1
|
Status: Creatistic
Join date: Jul 2006
Location: Arizona
Expertise:
Software:
Posts: 1,726
|
Need some more help, few PHP things.
I have my image uploading script, with a register and what not.
Right now, when you register, your username requires to be 6 characters, and same with password.
Here is my 'register' config.
Code:
<?php include("conf.php"); ?>
<?php
$act = $_GET['act'];
if ($act == "dosignup")
{
sign_up($_POST['username'], $_REQUEST['password1'], $_REQUEST['password2'], $_REQUEST['email'], $_REQUEST['firstname'], $_REQUEST['lastname']);
}
function sign_up($username, $password1, $password2, $email, $firstname, $lastname)
{
$md5_pass = md5($password1);
if (! $password1 || ! $password2 || ! $email || ! $username)
{
$error = "Must enter username and password and email.";
}
else if( $password1 != $password2 )
{
$error = "Your passwords do not match.";
}
else if (strlen($username) < 6)
{
$error = "Username must be over 6 characters";
} else if (eregi('[!@#$%^&*()<>]', $username))
{
$error = "Invalid Characters in the username field";
}
else if (eregi('[!@#$%^&*()<>]', $password1) || eregi('[!@#$%^&*()<>]', $password2))
{
$error = "Invalid Characters in the password field";
}
else if (eregi('[!#$%^&*()<>]', $email))
{
$error = "Invalid Characters in the email field";
}
else if (eregi('[!@#$%^&*()<>]', $firtsname))
{
$error = "Invalid Characters in the first name.";
} else if (eregi('[!@#$%^&*()<>]', $lastsname))
{
$error = "Invalid Characters in the last name.";
}
if (! $error)
{
$numRows = mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `username`='$username'"));
if ($numRows > 0)
{
$error = "That account already exists.";
}
if (! $error)
{
$insert_query = mysql_query("INSERT INTO `users`(username, password, email, registration_date) VALUES('$username', '$md5_pass', '$email', CURRENT_DATE())") or die(mysql_error());
if (! $insert_query)
{
$error = "Could not create account.";
} else {
main_view('Signup Form', 'Congratulations. Your account '.$username.' has been created. Please login to the left.');
exit;
}
}
}
if ($error) { main_view('Login Error', "<b><font face='verdana' size='2'>Error: </b>".$error); exit; }
}
if ($act != "dosignup")
{
?> <h2><?php echo $website_name; ?> - Register</h2><br />
<p> Please ensure that the below information is correct, otherwise you may not be able to retreive and use your account at a later stage.</font><br /><br />
<form action='signup.php?act=dosignup' method='post'>
<table width='100%' cellpadding='2' border='0'><tr><td bgcolor='#F0FFFF' width='100%'><font size='2' face='sans-serif'>Account Information</font></td></tr></table>
<table width='400' border='0'>
<tr>
<td with='35%'><font size='2' face='sans-serif'>Desired Username:</font></td>
<td width='65%'><input type='text' name='username' size='20'></td>
</tr>
<tr>
<td width='35%'><font size='2' face='sans-serif'>Desired Password:</font></td>
<td width='65%'><input type='password' name='password1' size='20'></td>
</tr>
<tr>
<td width='35%'><font size='2' face='sans-serif'>Password (Again):</font></td>
<td width='65%'><input type='password' name='password2' size='20'></td>
</tr>
<tr>
<td width='35%'><font size='2' face='sans-serif'>Email:</font></td>
<td width='65%'><input type='text' name='email' size='20'>
</tr>
</table>
<br />
<center><input type='submit' value='Create Account'></center>
</form>
</p>
</div>
<?php
}
?>
<?php include_once("functions/footer.php"); ?>
I changed
Code:
else if (strlen($username) < 6)
to a 4, and it let me register with a 4 letter name, but after I tired to actually log in, it told me I had to have a 6 letter name, even though I registered.
I cant figure it out.
You can see a demo at http://www.click2host.us/index.php , Can anyone help?
|
|
11-23-2006, 12:44 PM
|
#2
|
Status: The BidMaster
Join date: Nov 2004
Location: England
Expertise:
Software:
Posts: 10,821
|
This is using a mysql right? I'm not great with php and stuff....but maybe you need to alter the the length of the field in the database.
|
|
11-23-2006, 12:53 PM
|
#3
|
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
Posts: 3,820
|
You'll have to change login2.php to reflect the change in length as well.
|
|
11-23-2006, 04:45 PM
|
#4
|
Status: Creatistic
Join date: Jul 2006
Location: Arizona
Expertise:
Software:
Posts: 1,726
|
My login2.php doenst say anything, but
Code:
<?php
$special_request=true;
inclide('confi.php");
check_login($_REQUEST['username'], $_POST['password']);
?>
so what do i change?
|
|
11-23-2006, 05:09 PM
|
#5
|
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
Posts: 5,200
|
Go into confi.php and then look for this line:
Code:
function check_login {
And find a line that says something like:
Code:
if (strlen($username) < 6)
or a modified version of that. Then, change it to four and you should be golden.
Robson, changing the field value won't help as that sets the limit (usually 25) and not the shortest it can be.
|
|
11-23-2006, 05:47 PM
|
#6
|
Status: Creatistic
Join date: Jul 2006
Location: Arizona
Expertise:
Software:
Posts: 1,726
|
None of that is in conf.php (there is no confi.php)
|
|
11-23-2006, 06:38 PM
|
#7
|
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
Posts: 5,200
|
Originally Posted by BrokenFaith
Code:
<?php
$special_request=true;
inclide('confi.php");
check_login($_REQUEST['username'], $_POST['password']);
?>
|
You say there is no confi.php yet the include says confi.php..
Also, change inclide to include.
|
|
11-23-2006, 06:52 PM
|
#8
|
Status: Creatistic
Join date: Jul 2006
Location: Arizona
Expertise:
Software:
Posts: 1,726
|
well, there is no confi.php. there is only conf.php, would you like my FTP? lol.
|
|
11-23-2006, 06:59 PM
|
#9
|
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
Posts: 5,200
|
I believe you, but if there is no confi.php, why do you have that in your files' include?
|
|
11-23-2006, 07:06 PM
|
#10
|
Status: Creatistic
Join date: Jul 2006
Location: Arizona
Expertise:
Software:
Posts: 1,726
|
I dont know, ask my coder
I can tripple check..
(BTW AJ, I got phpadnews installed.)
Yeah after just checking, htere is no confi, its conf.php
|
|
|
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|