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.
- 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