Also, when I retry this(refreshing the page), I get message (1) again.
The register file in a folder called 'actions', which is inside a folder called 'cms'.
This is the PHP code:
- Code: Select all
<?php
session_start();
if(isset($_SESSION['user'])!="")
{
header("Location: ../mainpage.php");
}
include_once '../includes/dbconnect.php';
if(isset($_POST['btn-signup']))
{
$uname = mysql_real_escape_string($_POST['uname']);
$email = mysql_real_escape_string($_POST['email']);
$upass = md5(mysql_real_escape_string($_POST['pass']));
if(mysql_query("INSERT INTO users(username,email,password) VALUES('$uname','$email','$upass')"))
{
?>
<script>alert('successfully registered ');</script>
<?php
}
else
{
?>
<script>alert('error while registering you...');</script>
<?php
}
}
?>
This is the form html:
<form class="form-signin"method="post">
<h2 class="form-signin-heading text-center">AlphaCMS</h2>
<label class="sr-only">User Name</label>
<input type="text" id="username" class="form-control" placeholder="User Name" required autofocus>
<label class="sr-only">Password</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign Me Up</button>
</form>
'mainpage.php' is where the page should go to next.
I don't know what's wrong so I can't fix it. Any help will be appreciated.
Thanks