Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1876 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Need some more help, few PHP things.

Thread title: Need some more help, few PHP things.
Closed Thread  
Page 1 of 2 1 2 >
    Thread tools Search this thread Display Modes  
11-23-2006, 07:16 AM
#1
BrokenFaith is offline BrokenFaith
BrokenFaith's Avatar
Status: Creatistic
Join date: Jul 2006
Location: Arizona
Expertise:
Software:
 
Posts: 1,726
iTrader: 5 / 100%
 

BrokenFaith is on a distinguished road

Send a message via AIM to BrokenFaith Send a message via MSN to BrokenFaith

  Old  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
DateinaDash is offline DateinaDash
Status: The BidMaster
Join date: Nov 2004
Location: England
Expertise:
Software:
 
Posts: 10,821
iTrader: 0 / 0%
 

DateinaDash is on a distinguished road

  Old

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
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

You'll have to change login2.php to reflect the change in length as well.

11-23-2006, 04:45 PM
#4
BrokenFaith is offline BrokenFaith
BrokenFaith's Avatar
Status: Creatistic
Join date: Jul 2006
Location: Arizona
Expertise:
Software:
 
Posts: 1,726
iTrader: 5 / 100%
 

BrokenFaith is on a distinguished road

Send a message via AIM to BrokenFaith Send a message via MSN to BrokenFaith

  Old

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
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

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
BrokenFaith is offline BrokenFaith
BrokenFaith's Avatar
Status: Creatistic
Join date: Jul 2006
Location: Arizona
Expertise:
Software:
 
Posts: 1,726
iTrader: 5 / 100%
 

BrokenFaith is on a distinguished road

Send a message via AIM to BrokenFaith Send a message via MSN to BrokenFaith

  Old

None of that is in conf.php (there is no confi.php)

11-23-2006, 06:38 PM
#7
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

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
BrokenFaith is offline BrokenFaith
BrokenFaith's Avatar
Status: Creatistic
Join date: Jul 2006
Location: Arizona
Expertise:
Software:
 
Posts: 1,726
iTrader: 5 / 100%
 

BrokenFaith is on a distinguished road

Send a message via AIM to BrokenFaith Send a message via MSN to BrokenFaith

  Old

well, there is no confi.php. there is only conf.php, would you like my FTP? lol.

11-23-2006, 06:59 PM
#9
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

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
BrokenFaith is offline BrokenFaith
BrokenFaith's Avatar
Status: Creatistic
Join date: Jul 2006
Location: Arizona
Expertise:
Software:
 
Posts: 1,726
iTrader: 5 / 100%
 

BrokenFaith is on a distinguished road

Send a message via AIM to BrokenFaith Send a message via MSN to BrokenFaith

  Old

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

Closed Thread  
Page 1 of 2 1 2 >


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed