Help (How to connect SQL DB functionally , )

Hi, I want to create login web site for student entering data , The db stored in phpmyadmin cpanel on byethost6.com, just made three pages for authentication , index.php, connect.php , mysql_connect.inc.php . After input data into index.php, functionally changed to connect.php , without query database and response from code i set .

The infrormation provided i have done for login system . Hope people could help me , thanks!

Link : http://www.starofphilology.byethost6.com
SQL COLUMN :
sch-code
password
email
sch-name
address
district

sever config
Server host :sql307.byethost6.com
$db_name = “db_star”;
$db_user = “root”;

(index.php)

Registration Account:
Paasword:

b[/b]

Student <?php session_start(); ?> <?php

include(“mysql_connect.inc.php”);
$id = $_POST[‘id’];
$pw = $_POST[‘pw’];

$sql = “SELECT * FROM account where schcode = ‘$id’”;
$result = mysql_query($sql);
$row = @mysql_fetch_row($result);

if($id != null && $pw != null && $row[1] == $id && $row[2] == $pw)
{

    $_SESSION['schcode'] = $id;
    echo 'Login successfully !';
    echo '<meta http-equiv=REFRESH CONTENT=1;url=member.php>';

}
else
{
echo ‘Failed!’;
echo ‘<meta http-equiv=REFRESH CONTENT=1;url=index.php>’;
}
?>

b[/b]

<?php

$db_server = “sql307.byethost6.com”;

$db_name = “db_star”;

$db_user = “root”;

$db_passwd = “123456”;

/
if(!@mysql_connect($db_server, $db_user, $db_passwd))
die("Doesn’t work ");

mysql_query(“SET NAMES utf8”);

if(!@mysql_select_db($db_name))
die(“Fail to connect the database”);
?>

Update the code. PDO or mysqli should be used for all new development.

Your database user should never be root, it opens up too many issues and too much control.

Thanks!

And for gawd sake, NEVER use the @ to suppress errors. Errors are your friend. They tell you when something is wrong.

Thx!!!

Useful to me 8)

Is it necessary to upload all files to cpanel or php files (config,index,phpinfo) only?
It means file uploaded in file manager.
Any instruction or guideline for me to study ?
Readme.txt seen , follow instruction to create db and named pdo_bumpstart exactly.
I was first to learn php , feel confused .

Thanks for your help!

Current status
http://www.starofphilology.byethost6.com/

Sponsor our Newsletter | Privacy Policy | Terms of Service