jeudi 13 août 2015

Having trouble executing the user id session after user logs in

Here is the following codes i have so far for the sign up page login page and homepage. note i am only posting the php I know everything is working except for the user id session. I am connected to my database and row 1 is id and is the primary key.

here is the signup php

<?php
require ("func/insert.php");

if(isset($_POST['Submit']))
    {
        $first_name = mysqli_real_escape_string($con, $_POST ['first_name']);
        $last_name= mysqli_real_escape_string($con, $_POST ['last_name']);
        $email= mysqli_real_escape_string($con, $_POST ['email']);
        $password= $_POST ['password'];

        $StorePassword= password_hash($password, PASSWORD_BCRYPT, array('cost' => 10));

        $sql = $con->query("INSERT INTO users ( first_name, last_name, email, password)
                    VALUES ( ' {$first_name} ' , ' {$last_name} ' , ' {$email} ' , ' {$StorePassword} ' )");
        header('Location: login.php');
    }
?>

HEre is the login php

<?php require ("func/insert.php"); ?>
<?php
    if(isset($_POST['Login']))
    {
    $email= mysqli_real_escape_string(htmlentities($con, $_POST ['email']));
    $password= mysqli_real_escape_string(htmlentities($con, $_POST ['password']));

    $result = $con->query(" select * from users where email='$email' AND password='$password' ");

    $row = $result->fetch_array(MYSQLI_BOTH);

    session_start();

    $_SESSION['UserID'] = $row['id']; //thinking this is the problem
    header ('Location: home.php');
    }

And here is the home php

<?php require ("func/insert.php"); ?>
<?php
session_start(); 
    if (isset($_SESSION['UserID'])) {
}
else {
echo "This session is not working.";
}
?>



via Chebli Mohamed

SQL: Choose from an array of items in a like clause with AND condition

I am trying to write some SQL which really needs an array of like this string and that string and so on, and to meet a datetime condition and make this syntax work as it should. All of this is psuedocode. For example [DueDate] >= someDateTimeControl.Value AND [Place] like "A", "B", "C"

So that only those places which qualify on the due date are also shown, A, B, C. I tried using AND [Place] like "A" Or [Place] like "B"... (so on) with the DueDate but it gets those places which do not meet the due date. So how would you array it so I could get the time and the place as any in the set that meet the time?



via Chebli Mohamed

how to do periodic migration from database to database using mapforce

I need help in migrating data from legacy database to the new database using MapForce. (Both databases are in MSSQL)

I am a student and I have pretty good knowledge of databases but bad at other languages.

Scenario

I have a CUSTOMER table in legacy database (We are still using legacy system) and a CLIENT table the new database (Which we need to populate before going live with new system)

I have already mapped fields between these two tables in MapForce and I have generated C# script.

Question

What to do next ? to make it work and migrate data from Database-1 to Database-2 between those tables?

How to do it periodically or only few records at t time so it won't affect the performance?

Will it also pick up the changes once the records are copied across ?

What I want to Achieve

I want to copy records from the "CUSTOMER" table from legacy system to the "CLIENT" Table in new system.

I also want the MapForce to re-copy them again if there are any changes in legacy records.



via Chebli Mohamed

PostgreSQL: Create an index to quickly distinguish NULL from non-NULL values

Consider a SQL query with the following WHERE predicate:

...
WHERE name IS NOT NULL
...

Where name is a textual field in PostgreSQL.

No other query checks any textual property of this value, just whether it is NULL or not. Therefore, a full btree index seems like an overkill, even though it supports this distinction:

Also, an IS NULL or IS NOT NULL condition on an index column can be used with a B-tree index.

What's the right PostgreSQL index to quickly distinguish NULLs from non-NULLs?



via Chebli Mohamed

Informix to SQL attribute constraint

I have a constraint as follows in my script & I learnt that it's Informix:

create table blaBla
{
 var_name_1 not null constraint n255_153,
 var_name_1 not null constraint n655_699,
}

I can't find an equivalent to this in SQL. I tried just typing it the same but it doesn't work. What's the equivalent in other DBMS?



via Chebli Mohamed

Is it Possible to create a relationship like this 1 to 0..1 + 0..1 to 1

Want to create the same RelationShip between Student and Result as i've created between Subject and Result is it possible ?? to create a relations like 1 to 0..1 -0..1 to 1??

Want to create the same RelationShip between Student and Result as i've created between Subject and Result is it possible ?? to create a relations like 1 to 0..1 -0..1 to 1??



via Chebli Mohamed

Google BigQuery - Parsing string data from a Bigquery table column

I have a table A within a dataset in Bigquery. This table has multiple columns and one of the columns called hits_eventInfo_eventLabel has values like below:

{ID:AEEMEO,Score:8.990000;ID:SEAMCV,Score:8.990000;ID:HBLION;Property ID:DNSEAWH,Score:0.391670;ID:CP1853;ID:HI2367;ID:H25600;}

If you write this string out in a tabular form, it contains the following data:

**ID      |   Score**
AEEMEO  |   8.990000
SEAMCV  |   8.990000
HBLION  |    -
DNSEAWH |   0.391670
CP1853  |    -
HI2367  |    -
H25600  |    -

Some IDs have scores, some don't. I have multiple records with similar strings populated under the column hits_eventInfo_eventLabel within the table.

My question is how can I parse this string successfully WITHIN BIGQUERY so that I can get a list of property ids and their respective recommendation scores (if existing)? I would like to have the order in which the IDs appear in the string to be preserved after parsing this data.

Would really appreciate any info on this. Thanks in advance!



via Chebli Mohamed