Jump to content

error while hosting


mariam

Recommended Posts

i wrote a for loging in a specific page.... logiing in just requires the username attribute.. no password is required.

 

it works fine on local host using xamp but when i host the website it gives the following error:

 

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'a3907930_root'@'10.1.1.42' (using password: NO) in /home/a3907930/public_html/doc_checklogin.php on line 15

 

following is the code:

 

<?php

$host = "mysql14.000webhost.com";
$db_name = "a3907930_mehreen";
$username = "a3907930_root";
$password = "aaaAAA111";
$tbl_name="members";
//$host="localhost"; // Host name 
//$username="root"; // Mysql username 
//$password=""; // Mysql password 
//$db_name="mehreen"; // Database name 
//$tbl_name="members"; // Table name

// Connect to server and select databse.
mysql_connect($host, $username)or die("cannot connect"); 
mysql_select_db($db_name)or die("cannot select DB");

// username sent from form 
$myusername=$_POST['myusername']; 

$sql="SELECT * FROM $tbl_name WHERE username='$myusername'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, and redirect to  profile file
  session_register("myusername");
}

//addition:
if ($myusername=='mariam') {
 header ("location:mariam_profile.php");
}

elseif ($myusername=='mehreen') {
 header ("location:mehreen_profile.php");
}

  ?>

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.