TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sizwe Pellicant
NA
2
1.5k
check if a user email is exist in database if user
Jun 1 2016 10:06 AM
<?php
session_start();
$conn = mysqli_connect("localhost", "ODBC", "", "spynews_db");
if(mysqli_connect_errno()){
echo "Unable to connect" .mysqli_connect_error();
exit();
}else{
if(isset($_POST["submit"])){
//echo $_POST["submit"];
$password = "";
$charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
for($i = 0; $i < 8; $i++){
$random_int = mt_rand();
$password .= $charset[$random_int % strlen($charset)];
}
//echo $password, "\n";
$sql = 'INSERT INTO users VALUES (?,?,?,?,?,?)';
$stmt = mysqli_stmt_init($conn);
if(mysqli_stmt_prepare($stmt,$sql)){
mysqli_stmt_bind_param($stmt,'ssssss',$user_email,$user_name,$user_surname,$user_date_of_birth,$user_gender,$password);
$user_name =$_POST["name"];
$user_surname =$_POST["surname"];
$user_gender =$_POST["gender"];
$user_date_of_birth =$_POST["dateofbirth"];
$user_email =$_POST["email"];
$to = $_POST["email"];
$from = "From:
[email protected]
";
if(!isset($_POST["email"]) || $_POST["email"] == null){
echo "Please enter a valid email address";
}else{
$result = mail($to, $_POST['name'],
$password,$from);
if(!$result){
echo "Error sending message";
}else{
echo "message sent";
}
}
mysqli_stmt_execute($stmt);
$stmt->close();
echo"User Registered";
$conn->close();
}else{
echo "Failed to Register";
}
}
}
?>
<html>
<head>
<title>Registration</title>
</head>
<div class="form">
<body bgcolor="#EAEAEA">
<img src="deliver.png" alt="flower" width="300" height="95" />
<center>
<fieldset style="width:50%"><legend><h3>Registration Form</h3></legend>
<table>
<form name="registration" action="RegisterForm.php" method="post">
<tr>
<td>Name:</td>
<td><input type="text" name="name" placeholder="Name" required /></td>
</tr>
<tr>
<td>Surname:</td>
<td><input type="text" name="surname" placeholder="Surname" required /></td>
</tr>
<tr>
<td>Gender:</td>
<td><input type="radio" name="gender" value="Male"/>Male
<input type="radio" name="gender" value="Female"/>Female
</tr>
<tr>
<td>D.O.B:</td>
<td><input type="date" name="dateofbirth" placeholder="Date Of Birth" required /></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="email" name="email" placeholder="Email" required /></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="Submit" /></td><br/>
</tr>
<tr>
<td><a href='Index.php'>Home</a></td>
<td><a href='Login.php'>Login</a></td>
</tr>
</form>
</div>
</body>
</html>
Reply
Answers (
1
)
how to populate data from mysql into dropdown using php
How to print log messages in PHP? like Java SOP statements ?