How would I make it so on the user being registered they get redirected to a different page. Ive tried most things, and yes it registers fine but im just struggling with this one bit D:
regsister.inc.php
<?php
//Start session:
session_start();
//Include db settings and create a connection:
include("config.inc.php");
//Create variable for username input and prevent sql injections:
$username = mysql_real_escape_string($_POST['usern2']);
//Create variable for password input, prevent sql injections and hash it with md5:
$password = mysql_real_escape_string(md5($_POST['pass2']));
//Select matching username and password from admin table based on input:
$sql = "INSERT INTO admin VALUES('$username', md5('$password'))";
//$sql = "SELECT * FROM admin WHERE username = '$username' AND password = '$password'";
//Execute query to db:
$execute = mysql_query($sql);
if (mysql_num_rows($execute) == 1) {
$_SESSION['user'] = $username;
echo "<p>Register Successful</p>";
}
register.php
<?php
include ("includes/register.inc.php");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<div id="container">
<?php echo $errormsg; ?>
<h2>Register</h2>
<form method="post" action="register.php">
<label>Username: </label>
<input type="text" size="25" name="usern2" value=""><br>
<label>Password: </label>
<input type="password" size="25" name="pass2" value=""><br>
<input type="submit" value="Register!">
</form>
</div>
</body>
</html>
Much help would be appreciated, dont roast me im new to PHP D: