I am using a form in html as a login. However when passing this info php to be validated I get an error from mysql statements.
A point in the right direction would be of great help. I've been stuck on this for quite a while. The error is recevied when tring to connect to the database i am using.[php]<?php
session_start() ;
$host="hostname ";
$user="username ";
$db_password="p assword";
$database="data base name";
$user_name = $_POST['user_name']; //this is from the html page
$password = $_POST['password']; //this is from the html page
$cxn = mysqli_connect( $host,$user,$db _password)or die("cannot connect");
mysqli_select_d b($database) or die("cannot connect to database");
$query = "SELECT * FROM table_name
WHERE user_name='$use r_name' AND password='$pass word'";
$result = mysqli_query($q uery, $cxn) or die ('error making query');
$affected_rows = mysqli_num_rows ($result);
if($affected_ro ws ==1) {
print 'validated';
}
else {
print 'not valid';
}
?>[/php]Thanks G
A point in the right direction would be of great help. I've been stuck on this for quite a while. The error is recevied when tring to connect to the database i am using.[php]<?php
session_start() ;
$host="hostname ";
$user="username ";
$db_password="p assword";
$database="data base name";
$user_name = $_POST['user_name']; //this is from the html page
$password = $_POST['password']; //this is from the html page
$cxn = mysqli_connect( $host,$user,$db _password)or die("cannot connect");
mysqli_select_d b($database) or die("cannot connect to database");
$query = "SELECT * FROM table_name
WHERE user_name='$use r_name' AND password='$pass word'";
$result = mysqli_query($q uery, $cxn) or die ('error making query');
$affected_rows = mysqli_num_rows ($result);
if($affected_ro ws ==1) {
print 'validated';
}
else {
print 'not valid';
}
?>[/php]Thanks G
Comment