Below is my html form:
<html>
<head>
<title>
Registration
</title>
</head>
<body>
<form action="backreg.php" method="post">
user id:<input type="text" name="rid"><br>
fname:<input type="text" name="rname"><br>
gender:
<select name="rgen">
<option value="male">male</option>
<option value="female">female</option>
</select><br>
dob:<input type="text" name="rdob"><br>
mobile:<input type="text" name="rmob"><br>
PASSWORD:<input type="password" name="rpwd">
<input type="submit" name="rsubmit" value="register">
</form>
<a href="index2.php" >already registered ?</a >
</body>
</html>
The corresponding php code (backreg.php) to capture the values entered in the above form is below:
<?php
$conn = mysqli_connect("localhost", 'root', '', 'manideep_db');
if(isset($_POST['rsubmit'] ))
{
$id=$_POST['rid'];
$name=$_POST['rname'];
$gender=$_POST['rgen'];
$dob=$_POST['rdob'];
$mobile=$_POST['rmob'];
$password=$_POST['rpwd'];
$run=mysqli_query($conn, "INSERT INTO `table_1` (`rid`, `rname`, `rgen`, `rdob`,'rmob','rpwd')VALUES ('$id', '$name', '$gender', '$dob','$mobile','$password')");
if($run)
{
header('Location: index2.php');
}
echo "error";
}
?>
manideep_db is my database name. table_1 is a table inside the db which contains the id, name, dob, gender, mobile and password fields. After filling the form and submitting, I'm getting output error instead of page getting redirected to index2.php. Please suggest what is going wrong in my code? Thanks.