Before I get into the specific issues, I want to provide some other details:

  • Normally, I work on a live, paid server (even in dev); I realize that is not advised, but it is a bad habit I developed over the years. I've tried using Xammp, but do not really care for that environment for various reasons. Recently, I stopped paying for web-hosting (GoDaddy,) and have been developing various scripts on a free host.

  • Overall, free hosting is quite limited, that is, many do not give access to error logs, for example. There are other vital features that are often paid-only.

I came across a new hosting site that seems fairly good for testing my scripts/mark up.

I am attempting to produce a registration form with email verification. My last script for a registration form (without email verifcation) worked perfectly, submitting all data to a database. Never any errors beyond incorrect PHP/MySQLi syntax.

I did not develp the particular code posted here, but am using it to learn how to implement email verification.

At this point, on this new server (and other free servers in the recent days,) I've been receiving errors (that never occurred with paid-hosting.)

Also, should it matter, I believe this current server is MS; I've only really only worked on Linux and it seems different. I'm not sure what the differences are (that the user must do more to set up users/permissions? I never had to do any of that on my paid, Linux hosting.

Initially I was receiving the following (Note: this the general error, not from my account specifically): "Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user '<dbuser>'@'stevie.heliohost.org' (using password: YES) in/home1/galiarm/public_html/config.php on line 2 Failed to connect to MySQL: Access denied for user '<dbuser>'@'stevie.heliohost.org' (using password: YES)"

  • I am certain my credentials are correct for connecting with my DB.

Last evening I was led to believe that this error may be occuring due to either header use or permissions; I edited the permissions to 777 (which is not secure, but at this point I'm only trying to solve this issue and connect to dummy data.

This led to Internal Serrver Error message; please see attached scrnsht of error message. ies1.jpg

  • I also attempted to edit .htaccess / Order allow,deny (a topic I am not too familiar with,) and received a blank, screen.

configdb.php

<?php
$con = mysqli_connect("******.heliohost.org","matj****","Ma***","********_userreg") or die("Database Error");

if ($con->connect_error) {
    die('Connect Error: ' . $con->connect_error);
}

?>

Register

$_SESSION['error']['password'] = "Password is required.";
}

//if the error exist, we will go to registration form
if(isset($_SESSION['error']))
{
header("Location: index.php");
exit;
}
else
{
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
$com_code = md5(uniqid(rand()));

$sql2 = "INSERT INTO user (username, email, password, com_code) VALUES ('$username', '$email', '$password', '$com_code')";
$result2 = mysqli_query($mysqli,$sql2) or die(mysqli_error());

if($result2)
{
$to = $email;
$subject = "Confirmation from TutsforWeb to $username";
$header = "TutsforWeb: Confirmation from TutsforWeb";
$message = "Please click the link below to verify and activate your account. rn";
$message .= "http://www.exampleDomain.com/confirm.php?passkey=$com_code";

$sentmail = mail($to,$subject,$message,$header);

if($sentmail)
{
echo "Your Confirmation link Has Been Sent To Your Email Address.";
}
else
{
echo "Cannot send Confirmation link to your e-mail address";
}
}
}
}

?>

index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sing Up</title>
<style>
label{
width:100px;
float:left;
}
</style>
</head>
<body>
<?php
session_start();
if(isset($_SESSION['error']))
{
echo '<p>'.$_SESSION['error']['username'].'</p>';
echo '<p>'.$_SESSION['error']['email'].'</p>';
echo '<p>'.$_SESSION['error']['password'].'</p>';
unset($_SESSION['error']);
}
?>
<div class="signup_form">
<form action="register.php" method="post" >
<p>
<label for="username">User Name:</label>
<input name="username" type="text" id="username" size="30"/>
</p>
<p>
<label for="email">E-mail:</label>
<input name="email" type="text" id="email" size="30"/>
</p>
<p>
<label for="password">Password:</label>
<input name="password" type="password" id="password" size="30 "/>
</p>
<p>
<input name="submit" type="submit" value="Submit"/>
</p>
</form>
</div>
<p><a href="login.php">Login</a></p>
</body>
</html>

I'll admit, at this point I'm confused about this: is it my code, an actual server error on the hosting end?

I emailed the webmaster at the hosting site (but have heard nothing back in reference to a potential internal server error.)

I may be getting the last few days' of errors mixed up, so I apologize if I am not clear in my posting here on Daniweb; I prefer to figure out these problems (and learn from them,) but at this time feel stuck.

I appreciate any help offered, or pointing out anything glaringly incorrect that may be causing these issues.

~Matty

You need to ensure that your user has privileges to connect to your database. Try connecting from the command line, use the grant command to add permissions to a user, and flush privileges to make sure they're applied.

Thanks, pty, I will try that now.

One question if I may: as I stated in the earlier post, I am using a free account at this time. I noticed in the account earlier that a free acount "does not grant access to Remote SQL"; I'm unfamiliar with Remote SQL - I've been researching what it is specifically.

Is it different than a standard connection to my database through my test site being hosted by the company, (what I would typically connect to via my laptop, for example,) or is it specifically a sort of permnission to let others (say in a network) to also connect to my DB and edit, etc? Basically, is Remote SQL different than what I've always used when testing a website?

Thanks much for your help.

You'd need to check with whoever is hosting your database. The error message you mention is coming from MySQL, so the connection to the DB appears to be fine, just the permissions for your particular user on the server are at fault.

You have several issues. You did not mention what version of Php you are using.

Per the manual (in big red box)

Warning
The mysqli->connect_error property only works properly as of PHP versions 5.2.9 and 5.3.0. Use the mysqli_connect_error() function if compatibility with earlier PHP versions is required.

In the index, session_start needs to come before any output, even blank spaces. Same for your login.php and register.php

Never ever put variables in a query. You need to use Prepared statements. I suggest you use PDO

Do not create variables for nothing.

You are outputting errors that may not even exist.

Do not output internal system errors to the user. That info is only good to hackers.

I suggest you start using HTML5

You have no validation checks of any sort.

Your register.php code seems to be missing some code at the top

Interested what you dont like about using XAMPP. It is an excellent development tool. As you know, you should never work on a live server.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.