This is the page code after clicked register button.Config.php works for db connection. It totally works . I have tried same mail and username already registered , it checks and not allow to retake it. so I think the problem start on $sql insertion line .There is no error showed up on php. It shows my function fail().
mysql_query($sql) was mysql_query($sql,$conn) before but I wanted to try if Its the problem however looks it isnt.
note: it was working on another hosting. I moved everything. Since , it stopped working.
Thank you.
<head>
<script>
function done() {
alert("Registration has been successful");
}
</script>
<script>
function fail() {
alert("Registration has been unsuccessful,Please try again");
}
</script>
<script>
function exist_username() {
alert("Username already has taken, please try again.");
}
</script>
<script>
function exist_mail() {
alert("You already has been registered.Please sign in.");
}
</script>
</head>
<body>
<?php
include("config.php");
if(isset($_POST['connect']))
{
if($conn)
{
$value=$_POST['name'];
$value2=$_POST['email'];
$value3=$_POST['password'];
$value4=$_POST['username'];
$check_username=mysql_query("SELECT username FROM member WHERE username='$value4'");
$check_mail=mysql_query("SELECT email FROM member WHERE email='$value2'");
if(mysql_num_rows($check_username)!=0)
{
echo '<script type="text/javascript">',
'exist_username();',
'</script>';
$URL="mywebsite.com";
echo '<META HTTP-EQUIV="refresh" content="0;URL=' . $URL . '">';
echo "<script type='text/javascript'>document.location.href='{$URL}';</script>";
}
if (mysql_num_rows($check_mail)!=0)
{
echo '<script type="text/javascript">',
'exist_mail();',
'</script>';
$URL="http://mywebsite.com";
echo '<META HTTP-EQUIV="refresh" content="0;URL=' . $URL . '">';
echo "<script type='text/javascript'>document.location.href='{$URL}';</script>";
}
else
{
$sql = "INSERT INTO member(name,email,password,username,registertime) VALUES('$value','$value2', '$value3', '$value4', CURRENT_TIMESTAMP )";
$retval = mysql_query($sql);
if($retval)
{
echo '<script type="text/javascript">',
'done();',
'</script>';
$URL="http://mywebsite.com";
echo '<META HTTP-EQUIV="refresh" content="0;URL=' . $URL . '">';
echo "<script type='text/javascript'>document.location.href='{$URL}';</script>";
}
else
{
echo '<script type="text/javascript">',
'fail();',
'</script>';
$URL="http://mywebsite.com";
echo '<META HTTP-EQUIV="refresh" content="0;URL=' . $URL . '">';
echo "<script type='text/javascript'>document.location.href='{$URL}';</script>";
}
}
}
else
{
die('Could not connect: DB ' . mysql_error());
}
}
?>
</body>
</html>