Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 692189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:37:30+00:00 2026-05-14T02:37:30+00:00

I tried this so far: <?php $error = ; $conn = pg_connect(host=localhost dbname=brittains_db user=brittains

  • 0

I tried this so far:

<?php

$error = "";

$conn = pg_connect("host=localhost dbname=brittains_db user=brittains password=XXXX" );

$sql = "SELECT * FROM logins";
$result = pg_query($conn, $sql);

if($_SERVER["REQUEST_METHOD"] == "GET") {
    $userName="";
    $password="";
}

else if($_SERVER["REQUEST_METHOD"] == "POST") {

    $userName=trim($_POST["userNameLogin"]);
    $password=trim($_POST["passwordLogin"]);

    if(pg_fetch_result($results, $userName, "userName")==true 
       && pg_fetch_result($results, $password, "userName")==true) {
        setcookie("userIDforDV", $userName, time()+43200);
    }
    else {
        $error = "Your username and or password is incorrect";
    }

}

$userName = $_COOKIE['userIDforDV'];

if(isset($userName) && $userName!="") {
    echo "Welcome " . $userName;
}

echo $error;

?>

<form action="<?php echo $_SERVER['PHP_SELF'];  ?>" method="post">
    <table>
        <tr>
            <td class="signupTd">
                User Name:&nbsp;
            </td>
            <td>
                <input type="text" name="userNameLogin" value="" size="20" />
            </td>
        </tr>
        <tr>
            <td class="signupTd">
                Password:&nbsp;
            </td>
            <td>
                <input type="password" name="passwordLogin" value="" size="20" />
            </td>
        </tr>
        <tr>
            <td class="signupTd" colspan="2">
                <input type="submit" name="submit" value="Submit"/>
            </td>
        </tr>
    </table>
</form>

That was the idea I came up with… but its probably a really bad idea and it doesn’t work… how might I go about this properly? I need really detailed descriptions please.

By the way, my SQL is:

CREATE TABLE logins(
    userName VARCHAR(25) NOT NULL PRIMARY KEY,
    password VARCHAR(25) NOT NULL,
    firstName VARCHAR NOT NULL,
    lastName VARCHAR NOT NULL,
    ageDay INTEGER NOT NULL,
    ageMonth INTEGER NOT NULL,
    ageYear INTEGER NOT NULL,
    email VARCHAR(255) NOT NULL,
    createDate DATE
);

and my registration form has already been made and is working and I do have users in my database, they just can’t login.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:37:31+00:00Added an answer on May 14, 2026 at 2:37 am

    check http://php.net/manual/en/function.pg-fetch-result.php ‘s comments.
    edit :
    password should be varchar(32) and use md5 passwords (or even better 64 and use sha1).
    also I’m not familiar with pgSQL in general, however IMO the correct way would be to use an sql query to check instead of using pg_fetch_result.

    $query = "SELECT * FROM logins WHERE userName = '$userName' AND password = md5('$password');";
    $result = pg_query($conn, $query);
    if(pg_num_rows($result) != 1) {
        // do error stuff
    } else {
        // user logged in
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried this: ALTER TABLE My.Table DROP MyField and got this error: -MyField is
I've tried install Apache, PHP, MySQL, and PHPMyAdmin manually and got the error. Then
Tried this: $('.link').click(function(e) { $.getScript('http://www.google.com/uds/api?file=uds.js&amp;v=1.0', function() { $('body').append('<p>GOOGLE API (UDS) is loaded</p>'); }); return
I tried this XAML: <Slider Width=250 Height=25 Minimum=0 Maximum=1 MouseLeftButtonDown=slider_MouseLeftButtonDown MouseLeftButtonUp=slider_MouseLeftButtonUp /> And this
I tried this but it does not seem to be valid syntax. <xsl:element name=$myElementName></xsl:element>
I tried this example in Perl. Can someone explain why is it true? if
I tried this code to open a file in Python: f = open("/Desktop/temp/myfile.txt","file1") It
I tried this, but could not get through:- code behind protected HtmlTableRow trComment; protected
I tried this aproach without any success the code I'm using: // File name
I tried this: def str1=good stuff 1) def str2 = str1.replaceAll('\)',' ') but i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.