Search
Left Quote    Choose a job you love, and you will never have to work a day in your life.
- Confucius    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: Help With Member System
  This user is offline  GrantDouglaso8
  Subject: "Help With Member System" Posted: @ 5:20 pm on Oct 13 2008   
Member #: 765
Rank: User - (3)
Since: 10/13/08
Posts: 3

When I Click Submit On The Registration Page I Get The Following Error Message
Code:

Warning: mysql_fetch_obj ect(): supplied argument is not a valid MySQL result resource in /home/grant1/pu blic_html/regis tration.php on line 38
No database selected
< br> .. here is my page code
Code:
<?
require_once($_ SERVER['DOCUMEN T_ROOT'].'/db_c onnect.php');
//SEE IF ALREADY LOGGED IN

if($_SESSION[' logged_in'] == 1)
{
//REDIRECT TO HOMEPAGE
header('Locatio n: http://' . $_SERVER['HTTP_ HOST'] . '');
} else {

if(isset($HTTP _POST_VARS['sub mit']))
{

//BEGIN CHECKING USERNAME...

if(!$_POST['use rname']) die('Alert: username field was blank.');

//array of invalid characters

//starting lenght of username
$len = strlen($_POST[' username']);

//replace invalid characters
$_POST['usernam e'] = str_replace($ju nk, '', $_POST['usernam e']);
$test = $_POST['usernam e'];

//if lenghts are different ($len smaller), invalid characters found, so prompt error.
if(strlen($test ) != $len) {
die('Username Error: Username contained invalid characters. You can only use A-Z, 0-9 and the

underscore (_).');
}

//Check if username already exists...

$q2 = mysql_query(&qu ot;SELECT * FROM `members` WHERE `username` = '".$_POST[ 'username'].&qu ot;'");
$q3 = mysql_fetch_obj ect($q2);

if($q3->user name == $_POST['usernam e']) {
die('<BR> ;<BR>Sorr y, but the username "'.$q3-> ;username.'&quo t; is taken, please choose another.');
}

//PASSWORD

if(!$_POST['pas sword']) {
die('Error: Password field was blank');
}
if(!$_POST['ver ify_password']) {
die('Error: Verify Password field was blank.');
}
if($_POST['pass word'] != $_POST['verify_ password']) {
die('Error: The passwords do not match.');
}
if(strlen($_POS T['password']) < 6 ) {
die('Error: Your password is too short. Must be 6 or more characters in length.');
}

//ADD NEW MEMBER

$insert ="INSERT INTO `members` (username, user_password, user_email) VALUES ('".$_POST ['username'].&q uot;',

'".md5($_P OST['password'] )."', '".$_POST[ 'email']." ')";

$insert2 = mysql_query($in sert);
if(!$insert2) die(mysql_error ());

echo('Registrat ion Successful, Welcome new member! You can now login to your new account.');

} else {
?>
<table> <form name="sign up" action="&l t;? $_SERVER['PHP_S ELF']; ?>" method="PO ST">
<tr>
<td>Usern ame: <BR> (only A-Z, 0-9 and _ Allowed)<BR& gt;</td>< br /> <td><i nput type="text " id ="username " name="user name" value="&qu ot; maxlength=" ;30"> <BR></ td>
</tr>
<tr>
<td>Passw ord:</td>
<td><i nput type="pass word" id="passwo rd" name="pass word" value="&qu ot; maxlength=" ;30">&l t;BR> (minimum 6

characters)< /td>
</tr>
<tr>
<td>Verif y Pass:</td> ;
<td><i nput type="pass word" id="verify _password" name="veri fy_password&quo t; value="&qu ot; maxlength=" ;30">&l t;BR>

</td>
</tr>
<tr>
<td>Email :</td>
<td><i nput type="text " id="email& quot; name="emai l" value="&qu ot; size="30&q uot;><br& gt;</td>< br /> </tr>
<tr>
<td>Click to Complete Signup:</td& gt;
<td><i nput type="subm it" id="submit " name="subm it" value="sub mit">&l t;/td>
</tr>
</form>< br /> </table>
<?
} //end not logged in
} //end submit not pressed
?>


can anyone fix this for me ?
thanks, Grant.


    Viewed: 5,941 Times | Reply to This | To top
  This user is offline  David1159
  Subject: "re: Help With Member System" Posted: @ 5:27 pm on Oct 15 2008    

Member #: 526
Rank: User - (81)
Since: 12/27/07
Posts: 81
From: usa

Something is wrong with your database.

Did you create a database?




Coding is simply CST... Combining $hit Together. We make different $hit to run in unison correctly.

    Viewed: 5,919 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Help With Member System" Posted: @ 9:04 pm on Oct 15 2008    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

If you're using the "db_conne ct" file as indicated in the article, be sure to enter in your user, pass, db name and so on.




-bs0d | AllSyntax.com

    Viewed: 5,913 Times | Reply to This | To top
  This user is offline  GrantDouglaso8
  Subject: "re: Help With Member System" Posted: @ 1:30 pm on Oct 16 2008    
Member #: 765
Rank: User - (3)
Since: 10/13/08
Posts: 3

I Got It Eventually, Cant Remember What i Did.. Just Messed About With It




    Viewed: 5,899 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank