Jump to content

PHP NEWBIE: problem with a function, easy solution?


tobeye

Recommended Posts

hello,

 

I'm a beginner when it comes to PHP:

I'm working on a log in system but i keep on getting the same errors which makes my system unreliable.

 

this is the function I'm trying to use:

 if(pg_numrows($q) == 1){
                echo "<p>Someone took that username</p>";
                include "signup.php";
                exit;
        }

--> I'm using a postgresql database

 

this is the warning I keep on getting:

Warning: pg_numrows(): supplied argument is not a valid PostgreSQL result resource in /var/ftpdirs/512544/PHP/login/adduser.php on line 13

 

 

I have the same problem when I try to look if an username is taken or not... when people try to register

 

 

 

this is my adduser.php file:

<?php
        session_start();
        include "connectie_db.php";
        $User_name = $_POST['user_name'] ;
        $User_pass = $_POST['user_pass'] ;
	$User_pass2 = $_POST['user_pass2'] ;
    $checkUsername= "SELECT user_name from tovanu.users where user_name = '$User_name';";
        $q = $db->exec($checkUsername);
	if(MDB2::isError($q)){
				echo "code: ".$q->getUserInfo();
				exit();
				}
        if(pg_numrows($q) == 1){
                echo "<p>Someone took that username</p>";
                include "signup.php";
                exit;
        }
        If(strlen($User_name > 32)){
                echo "<p>The username is too long</p>";
                include "signup.php";
                exit;
        }
        if($User_pass != $User_pass2){
                echo "<p>Both passwords must be the same</p>";
                include "signup.php";
                exit;
        }
        $password = md5($User_pass);
        
        $add = "INSERT INTO tovanu.users
(user_name,user_pass,user_email,user_date,user_level,naam,adres,plaats,postcode)
VALUES	('$User_name','$password','email',current_date,1,'jef','jonhstraat','maaseik','3687')";	
        
        $execute = $db->exec($add) ;
        
        	if(MDB2::isError($execute)){
				echo "code: ".$q->getUserInfo();
				exit();
				}

        $_SESSION['user'] = $username;
       
	include "index.php";
        ?>
        

 

 

any help would be appreciated!!!!!!!!!!!

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.