A
Anonymous
Guest
I try to make registration on my site .
but I cant insert data to my data base in the phpmyadmin
but I cant insert data to my data base in the phpmyadmin
Code:
<?php
$db_user="root";
$db_pass ="";
$db_name="project";
$db = new PDO('mysql:host=localhost;dbname=' . $db_name . ';charset=utf8', $db_user, $db_pass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
?>
Code:
<?php require_once('confing.php'); ?>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<style></style>
<title>Registration</title>
<link rel="stylesheet" href="forweb.css" type="text/css" />
<link rel="stylesheet" href="select.css" type="text/css" />
</head>
<body>
<div class="row">
<ul class="main-nav">
<li><a href="Connect.html">Connect</a></li>
<li> <a href="Info.html">Information</a></li>
<li><a href="about.html">About</a></li>
<li><a href="Registration.html">Registration</a></li>
<li class="active"><a href="Home.html">Home</a></li>
</ul>
</div>
<?php
if (isset($_post['submit']))
{
$first_name =$_post ['first_name'];
$last_name =$_post ['last_name'];
if(isset($_POST['gander'])){
$gander = $_POST(['gander']);
}
$password1 = $_post['password1']; $password2 =$_post['password2'];
if($password1==$password2)
{
$password = $password1;
}
$email = $_post['email'];
$sql="INSERT INTO users(first_name,last_name,gander,password,email) VALUES (?,?,?,?,?)";
$stmtinsert = $db->prepare($sql);
$result = $stminsert->execute([$first_name, $last_name, $gander, $password , $email]);
if($result)
{
echo 'Successfuly.';
}
else
{
echo 'error.';
}
}
else
{
echo 'No data';
}
?>
<form id='Register' action='Registration.php' method='post'>
<table style="font-size:25px; font-weight:bold; color:white; font-family:Roberto;">
<tr><td> <h6><u>Registration Page</u></h6> </td></tr>
<tr><td> <h3>Plaese Enter your full name here:</h3> </td></tr>
<tr><td> <input id="first_name" name="first_name" type="text" placeholder="First name" /> </td> </tr>
<tr><td> <input id="last_name" name="last_name" type="text" placeholder="Last name" /> </td> </tr>
<tr><td> <h3>Plaese Enter your gander :</h3> </td></tr>
<tr><td> <input id="Gender" name="Gender" type="radio" value="Male" />Male </td> </tr>
<tr><td> <input id="Gender" name="Gender" type="radio" value="Female" />Female </td> </tr>
<tr><td> <h3>Plaese Enter your password ( 8 numbers min) :</h3> </td></tr>
<tr><td> <input id="password1" name="password1" type="password" placeholder="password" /> </td> </tr>
<tr><td> <input id="password2" name="password2 " id="" type="password" placeholder="password again" /> </td> </tr>
<tr><td> <h3>Plaese Enter your email :</h3> </td></tr>
<tr><td> <input id="email" name="email" id="email" type="email" placeholder="email" /> </td> </tr>
<tr>
<td>
<input id="reset" type="Reset" value="Reset" />
<input name="submit" id="submit" type="submit" value="submit" />
</td>
</tr>
</table>
</form>
</body>
</html>