Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!

Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  yordan : (19 June 2013 - 02:28 PM) Long Life To Asta New Era
@  agyat : (19 June 2013 - 01:58 PM) New Era Start At Asta Or Asta Start In New Era. :unsure:
@  yordan : (16 June 2013 - 05:41 PM) You're Welcome, Agyat!
@  agyat : (16 June 2013 - 07:38 AM) Thanks Yordan...
@  velma : (16 June 2013 - 12:06 AM) I Have Asked Opa To Check For A Backup.. He'll Let Me Know Soon :)
@  velma : (16 June 2013 - 12:05 AM) T_T It Seems That Someone Has Deleted That Topic Since I Found The Url Of The Topic But It Gives Me An Error
@  yordan : (15 June 2013 - 10:31 PM) @velma : It's A Tuto On How To Create A Login Program.
@  yordan : (15 June 2013 - 10:31 PM) Happy Birthday To Youuuuuu Agyat!
@  yordan : (15 June 2013 - 10:31 PM) Ba$
@  agyat : (15 June 2013 - 04:41 PM) :(
@  agyat : (15 June 2013 - 04:41 PM) Where The Hall I Were? 15Th Is Almost At End And No-One Wished Me "happy Birthday"!!!
@  velma : (14 June 2013 - 10:39 AM) Which Tutorial Is He Searching For?
@  velma : (14 June 2013 - 10:38 AM) Which Tutorial Is He Searching For?
@  yordan : (14 June 2013 - 07:47 AM) Ok, Have A Look Tomorrow.
@  yordan : (13 June 2013 - 03:19 PM) @velma, Can You Have A Look At Feelay's Problem? Seems That His Tutorial Is Not Searchable Today.
@  Feelay : (13 June 2013 - 08:11 AM) Oh, Haha
@  velma : (12 June 2013 - 05:39 PM) T_T Lately My Levels Of Procrastination..... **sigh**
@  velma : (12 June 2013 - 05:38 PM) I'll Do It Later
@  velma : (12 June 2013 - 05:38 PM) Procrastinators.. People Who Keep Saying "i'll Do This In A Bit"
@  Feelay : (12 June 2013 - 02:05 PM) Deal Punishments To What?

Replying to A Simple Register Script


Post Options

    • Can't make it out? Click here to generate a new image

  or Cancel


Topic Summary

mikekandf

Posted 12 January 2012 - 03:49 PM

help how is this not working ????? im new btw lol


<?php

if(

isset( $_POST['user'] ) &&

isset( $_POST['pass'] )

)

{

if( strlen( $_POST['user'] ) < 4 )

{

echo "Username Must Be More Than 4 Characters.";

}

elseif( strlen( $_POST['pass'] ) < 4 )

{

echo "Passwrod Must Be More Than 4 Characters.";

}

elseif( $_POST['pass'] == $_POST['user'] )

{

echo"Username And Password Can Not Be The Same.";

}

else

{

include( 'database.php' );

$username = mysql_real_escape_string( $_POST['user'] );

$password = md5( $_POST['pass'] );

$sqlCheckForDuplicate = "SELECT username FROM user WHERE username = '". $username
."'";



if( mysql_num_rows( mysql_query( $sqlCheckForDuplicate ) ) == 0 )

{

$sqlRegUser = "INSERT INTO

user( username, password )

VALUES(

'". $username ."',

'". $password ."'

)";

if( !mysql_query( $sqlRegUser ) )

{

echo "You Could Not Register Because Of An Unexpected Error.";

}

else

{

echo "You Are Registered And Can Now Login";

$formUsername = $username;

header ('location: Login.php');

}

}

else

{

echo "The Username You Have Chosen Is Already Being Used By Another User. Please Try Another
One.";

$formUsername = $username;

}

}

}

else

{

echo "You Could Not Be Registered Because Of Missing Data.";

}

?>



please help

yordan

Posted 13 April 2011 - 12:12 PM

Hm...

You shouldn't use localhost. What is your host?

Usually, "localhost" is the host where the php program is being executed. The php scripts are on the remote host, and the database usually is on the same host as the php script.
Of course, you could also imagine a fully distributed situation, where the php scripts are on one host, the images are on a second host and the database is on a third host. In that case, instead of "localhost" you will have to provide the name of the computer hosting the database.
Fortunately, in most of "Linux + Apache + php + mysql" hosts, all the services are on the same physical machine, so the database is local to the system running the php script, and "localhost" is suitable for reaching the database.

Yenwood

Posted 13 April 2011 - 11:46 AM

Hm...

You shouldn't use localhost. What is your host?

frazz86

Posted 26 August 2010 - 07:47 AM

Is your host 'localhost' and what are you using to host your website please as some websites have there own hostname...
I think thats the error i know 000webhost(free) has a different host name.

Boswell

Posted 25 August 2010 - 11:17 PM

Look at your database.php

At line 1 you may have <?

Try changing that to <?php

See if that helps.

Feelay

Posted 12 August 2010 - 11:06 PM

My guess is that your database connection is at fault, and now I mean the username, password and host.
You should double check it and make sure that it's correct.

It's not supposed to be like the ones in the tutorial, it's supposed to be replaced with your MySQL account information =)

silence

Posted 12 August 2010 - 10:57 PM

Thanks, here's the regcheck:

<?php
if(
	isset( $_POST['user'] ) &&
	isset( $_POST['pass'] )
)
{
	if( strlen( $_POST['user'] ) < 4 )
	{
		echo "Username Must Be More Than 4 Characters.";
	}
	elseif( strlen( $_POST['pass'] ) < 4 )
	{
		echo "Passwrod Must Be More Than 4 Characters.";
	}
	elseif( $_POST['pass'] == $_POST['user'] )
	{
		echo"Username And Password Can Not Be The Same.";
	}
	else
	{
		include( 'database.php' );

		$username = mysql_real_escape_string( $_POST['user'] );
		$password = md5( $_POST['pass'] );

		$sqlCheckForDuplicate = "SELECT username FROM user WHERE username = '". $username ."'";

		
		if( mysql_num_rows( mysql_query( $sqlCheckForDuplicate ) ) == 0 )
		{
			$sqlRegUser =	 "INSERT INTO
						user( username, password )
					VALUES(
						'". $username ."',
						'". $password ."'
						)";

			if( !mysql_query( $sqlRegUser ) )
			{
				echo "You Could Not Register Because Of An Unexpected Error.";
			}
			else
			{
				echo "You Are Registered And Can Now Login";
				$formUsername = $username;
				
				header ('location: Login.php');
			}
		}
		else
		{
			echo "The Username You Have Chosen Is Already Being Used By Another User. Please Try Another One.";
			$formUsername = $username;
		}
	}
}
else
{
	echo "You Could Not Be Registered Because Of Missing Data.";
}
?>

Feelay

Posted 12 August 2010 - 10:31 PM

Try changing

mysql_select_db('register_database');

to

mysql_select_db('register_database') or die(mysql_error());

also, please show my your regcheck.php

silence

Posted 12 August 2010 - 10:27 PM

<?

$con = mysql_connect('---','---','---');

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }



mysql_select_db('register_database');

?>

Feelay

Posted 12 August 2010 - 09:45 PM

Show me your database.php

Remember to hide the username, password and host.

Review the complete topic (launches new window)