I wish to either make use of a freely available email validator (software, script or online service). There's work but when I insert more than one email at that time only one email verifies which I insert last and other email does not verify. Only one email verifies. How can I do it?
My code:
<?php
include_once('config.php');
if(isset($_POST["email_verify_btn"])) {
$email = $_POST["email_verify"];
if(strpos($email,"\n")) {
$text = explode("\n",$email);
} else {
$text = array($email);
}
function domain_exists($text)
{
$domain = substr(strrchr($text, "#"), 1);
$arr = #dns_get_record($domain, DNS_MX);
if ($arr[0]['host'] == $domain && !empty($arr[0]['target'])) {
return $arr[0]['target'];
}
}
foreach ($text as $abc) {
$domain = "";
$target = "";
$target_ip = "";
if(filter_var($abc, FILTER_VALIDATE_EMAIL)) {
if(domain_exists($abc)){
$domain = substr(strrchr($abc, "#"), 1);
$data = #dns_get_record($domain, DNS_MX);
if (is_array($data) || is_object($data)) {
foreach ($data as $key1) {
$host = $key1['host'];
$target = $key1['target'];
$target_ip = gethostbyname($key1['target']);
}
}
if($data) {
$status = "email id is valid";
}
} else {
$status = "mx recored not exist";
}
} else {
$status = "not in syntax";
}
$c_by = 1;
$c_date = date('Y-m-d H:i:s');
$c_ip = $_SERVER['REMOTE_ADDR'];
$insert = $connect->query("INSERT INTO `email_verify_list`(`primary_email`,`host_name`,`target`,`target_ip`,`session`,`status`,`created_by`, `created_date`, `created_ip`) VALUES ('$abc','$domain','$target','$target_ip','$c_date','$status','$c_by','$c_date','$c_ip')");
if($insert == 1) {
$_SESSION['date_time'] = $c_date;
} else {
echo "<script>alert('!!!!!not successfully');</script>";
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8"/>
<meta charset="utf-8"/>
<title>BULK EMAIL VARIFIER</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"/>
<link rel="apple-touch-icon" href="pages/ico/60.png">
<link rel="apple-touch-icon" sizes="76x76" href="pages/ico/76.png">
<link rel="apple-touch-icon" sizes="120x120" href="pages/ico/120.png">
<link rel="apple-touch-icon" sizes="152x152" href="pages/ico/152.png">
<link rel="icon" type="image/x-icon" href="favicon.ico"/>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta content="" name="description"/>
<meta content="" name="author"/>
<link href="assets/plugins/pace/pace-theme-flash.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/bootstrapv3/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/jquery-scrollbar/jquery.scrollbar.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="assets/plugins/switchery/css/switchery.min.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="pages/css/pages-icons.css" rel="stylesheet" type="text/css" />
<link class="main-stylesheet" href="pages/css/pages.css" rel="stylesheet" type="text/css"/>
<!--[if lte IE 9]>
<link href="assets/plugins/codrops-dialogFx/dialog.ie.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
</head>
<body class="fixed-header ">
<div id="rootwizard" class="m-t-50">
<ul class="nav nav-tabs nav-tabs-linetriangle nav-tabs-separator nav-stack-sm">
<li class="active">
<a data-toggle="tab" href="#tab1"><span>EMAIL VERIFY</span></a>
</li>
</ul>
<form method="post" action="" >
<div class="tab-content">
<div class="tab-pane padding-20 active slide-left" id="tab1">
<div class="row row-same-height">
<div class="col-md-12">
<div class="padding-30">
<div class="row clearfix">
<div class="col-sm-3">
<div class="form-group form-group-default">
<label><font size="2">ENTER YOUR EMAIL <span class="glyphicon glyphicon-envelope"></span></font></label><br>
<textarea cols="43" rows="9" name="email_verify" style="border-color:white;border-width:thin;padding:4pt;" multiple/></textarea><br>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-3">
<button type="submit" name="email_verify_btn" class="btn btn-lg btn-info" style="padding:11pt;width:200px;"/><span><b><font size="2">SUBMIT</font></b></span></button>
</div>
</div> <br><br>
<div class="row clearfix">
<div class="col-sm-12">
<table width="100%" class="table ">
<tr class="success">
<th>PRIMARY EMAIL <span class="glyphicon glyphicon-envelope"></span></th>
<th>HOST NAME</th>
<th>TARGET</th>
<th>TARGET IP</th>
<th>STATUS</th>
</tr>
<?php
$select = $connect->query("SELECT * from `email_verify_list` where session='".$_SESSION['date_time']."' order by id");
while($row = $select->fetch_assoc()) {
?>
<tr>
<td><?php echo $row['primary_email']; ?></td>
<td><?php echo $row['host_name']; ?></td>
<td><?php echo $row['target']; ?></td>
<td><?php echo $row['target_ip']; ?></td>
<td><?php echo $row['status']; ?></td>
</tr>
<?php } ?>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<script src="assets/plugins/pace/pace.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="assets/plugins/modernizr.custom.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrapv3/js/bootstrap.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery/jquery-easy.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-unveil/jquery.unveil.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-bez/jquery.bez.min.js"></script>
<script src="assets/plugins/jquery-ios-list/jquery.ioslist.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-actual/jquery.actual.min.js"></script>
<script src="assets/plugins/jquery-scrollbar/jquery.scrollbar.min.js"></script>
<script type="text/javascript" src="assets/plugins/classie/classie.js"></script>
<script src="assets/plugins/switchery/js/switchery.min.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap3-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<script type="text/javascript" src="assets/plugins/jquery-autonumeric/autoNumeric.js"></script>
<script type="text/javascript" src="assets/plugins/bootstrap-tag/bootstrap-tagsinput.min.js"></script>
<script type="text/javascript" src="assets/plugins/jquery-inputmask/jquery.inputmask.min.js"></script>
<script src="assets/plugins/bootstrap-form-wizard/js/jquery.bootstrap.wizard.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-validation/js/jquery.validate.min.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js" type="text/javascript"></script>
<script src="assets/plugins/summernote/js/summernote.min.js" type="text/javascript"></script>
<script src="assets/plugins/moment/moment.min.js"></script>
<script src="assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
<script src="assets/plugins/bootstrap-timepicker/bootstrap-timepicker.min.js"></script>
<script src="pages/js/pages.min.js"></script>
<script src="assets/js/form_wizard.js" type="text/javascript"></script>
<script src="assets/js/scripts.js" type="text/javascript"></script>
<script src="assets/js/demo.js" type="text/javascript"></script>
<script>
window.intercomSettings = {
app_id: "xt5z6ibr"
};
</script>
</body>
</html>
I think , you are not using strpos function in correct way.
you can use this way . Because strpos return also 0 value if any string found at zero position . and return FALSE if search string not found
Also note that string positions start at 0, and not 1.
if(strpos($email,"\n")!==false) {
$text = explode("\n",$email);
} else {
$text = array($email);
}
Related
In a very basic login page I set up an error status to show if the form was submitted with an empty pin or an invalid pin was entered but it only functions if I submit the form twice with the same error.
Where am I going wrong here?
Or else what would be a better way to achieve this?
<?php
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
?>
<html>
<head>
<title>Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
</head>
<body>
<h1>Page Title</h1>
<div class="smallcontainer">
<form method="post" action="">
<div class="row">
<div class="col-20">
<label for="id">Driver Pin</label>
</div>
<div class="col-80">
<input type="text" name="id" >
</div>
</div>
<div class="row">
<div class="col-100 error">
<?= #$_SESSION['status'] ?>
</div>
<div class="col-100">
<input type="submit" value="Submit" name="submit">
</div>
</div>
</form>
</div>
</body>
</html>
<?php
if (isset($_POST['submit'])) {
$id = trim($_POST['id']);
if (empty($_POST['id'])){
$_SESSION['status'] = 'Enter a Driver Pin';
}
// if (!strlen($id)) {
// $_SESSION['status'] = 'Enter a Driver Pin';
// //die('Please enter Driver Pin');
// }
$success = false;
$handle = fopen("users.csv", "r");
while (($data = fgetcsv($handle)) !== FALSE) {
if ($data[0] == $id) {
$success = true;
$_SESSION['displayname'] = $data[1];
break;
}
}
fclose($handle);
if ($success) {
$_SESSION['allow'] = '';
header('Location: ./');
} else {
$_SESSION['status'] = 'Invalid Driver Pin - Try again';
}
}
?>
First you need to put the php before the form (as already said) and here is your code with a few fixes:
<?php
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
if (isset($_POST['submit'])) {
$id = trim($_POST['id']);
$success = false;
$handle = fopen("users.csv", "r");
while (($data = fgetcsv($handle)) !== FALSE) {
if ($data[0] == $id) {
$success = true;
$_SESSION['displayname'] = $data[1];
break;
}
}
fclose($handle);
if ($success) {
$_SESSION['allow'] = '';
$_SESSION['status'] = 'Success!';
/*header('Location: ./');*/
} else {
if (empty($_POST['id'])){
$_SESSION['status'] = 'Enter a Driver Pin';
} else {
$_SESSION['status'] = 'Invalid Driver Pin - Try again';
}
}
} else {
$_SESSION['status'] = 'Enter a Driver Pin';
}
?>
<html>
<head>
<title>Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
</head>
<body>
<h1>Page Title</h1>
<div class="smallcontainer">
<form method="post" action="">
<div class="row">
<div class="col-20">
<label for="id">Driver Pin</label>
</div>
<div class="col-80">
<input type="text" name="id" >
</div>
</div>
<div class="row">
<div class="col-100 error">
<?= #$_SESSION['status'] ?>
</div>
<div class="col-100">
<input type="submit" value="Submit" name="submit">
</div>
</div>
</form>
</div>
</body>
</html>
This will work - notice I added an else if there is no post on fresh load you need to reset the $_SESSION['status'];
You php that checks and set status is located after HTML, which means the HTML returned by the page submission will not have the status updated until next submission.
So, move your PHP code above HTML.
Also, you can't use header() after anything was printed out already.
This is error showing page.i cant find any clues why showing these errors. The image file is not copying the images folder.
Notice: Undefined index: image in C:\xampp\htdocs\Project\Manpower.php on line 36
Notice: Undefined index: image in C:\xampp\htdocs\Project\Manpower.php on line 38
Warning: copy(): Filename cannot be empty in C:\xampp\htdocs\Project\Manpower.php on line 38
<?php
include_once'db_connect.php';
session_start();
$mysqli = new mysqli("localhost", "root", "", "travelagent");
if(isset($_POST['status']))
{
if (!isset($_SESSION["username"]))
{
$message = "please login!!";
echo "<script type='text/javascript'>alert('$message');</script>";
}
else
{
$id = mysqli_real_escape_string($mysqli, $_POST['id']);
$username=$_SESSION["username"];
$_SESSION['id']=$id;
$sql = "UPDATE product SET status='1' WHERE id='$id' " ;
if(mysqli_query($mysqli,$sql)==true)
{
$image_path= mysqli_real_escape_string( $mysqli ,'images/'.$_FILES['image']['name']);
if(copy($_FILES['image']['tmp_name'],$image_path))
{
$_SESSION['image']=$image_path;
$image=$_SESSION['image'];
$sql="INSERT INTO cart (user_name, product_id,image) VALUES ('$username','$id','$image')";
$result=$mysqli->query($sql);
$message = "added to cart!! ";
echo "<script type='text/javascript'>alert('$message');</script>";
session_destroy();
}
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Polyworld Services</title>
<meta name="Description" content="Polyworld">
<meta name="viewport" content="width:device-width" initial-scale="1">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script
src="https://code.jquery.com/jquery-2.2.4.js"
integrity="sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI="
crossorigin="anonymous"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/full-slider.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body data-spy="scroll" data-target="#my-navbar">
<?php
include'header.php';
?>
<h1 style="text-align:center;">Welcome to Manpower page</h1>
<div class="row" id="content">
<?php
$result=$mysqli->query("SELECT * FROM product WHERE category_id='1' AND sub_category_id='1' AND status='0'" );
while($row=$result->fetch_array())
{
?>
<div class="col-md-3">
<ul>
<li>picture : <?php echo "<img src='admin/".$row['image']. "' height='200' width='200'>"; ?> </li>
<li>Name: <?php echo $row['name']; ?></li>
<li>Description :<?php echo $row['description']; ?></li>
<li >Details</li>
<form action="" method="post">
<input type="text" name="id" value="<?php echo $row['id']; ?>">
<input type="hidden" name="image" value="<?php echo $row['image']; ?>">
<li><input type="submit" name="status" value="add to cart"></li></br>
</form>
</ul>
</div>
<?php
}
?>
</div>
<?php include'footer.php'; ?>
<script type="text/javascript">
</script>
</script>
<script type="text/javascript" src="js/custom.js">
</script>
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</body>
</html>
Try this code to upload file
$dir="image/";//name of the folder where the file need to be copied
$file=$dir . basename($_FILES["photo"]["name"]);// where 'photo' is the field name of file input
$filetype=pathinfo($file,PATHINFO_EXTENSION);
if(move_uploaded_file($_FILES["photo"]["tmp_name"], $file)) {
echo "upload success";
}
I have error when trying to insert data in databse, i get the following message:
Notice: Undefined variable: host in C:\wamp64\www\email_verify\index.php on line 53
Notice: Undefined variable: target in C:\wamp64\www\email_verify\index.php on line 53
Notice: Undefined variable: target_ip in C:\wamp64\www\email_verify\index.php on line 53
Fatal error: Cannot redeclare domain_exists() (previously declared in C:\wamp64\www\email_verify\index.php:13) in C:\wamp64\www\email_verify\index.php on line 13
how can i solve it....?
<?php
include_once('config.php');
if(isset($_POST["email_verify_btn"])) {
$email = $_POST["email_verify"];
if(strpos($email,"\n")) {
$text = explode("\n",$email);
foreach ($text as $abc) {
function domain_exists($abc)
{
$domain = substr(strrchr($abc, "#"), 1);
$arr = #dns_get_record($domain, DNS_MX);
if ($arr[0]['host'] == $domain && !empty($arr[0]['target'])) {
return $arr[0]['target'];
}
}
if(domain_exists($abc)){
$domain = substr(strrchr($fetch_email, "#"), 1);
$data = #dns_get_record($domain, DNS_MX);
if($data) {
$status = "email id is valid";
}
if (is_array($data) || is_object($data)) {
foreach ($data as $key1) {
$host = $key1['host'];
$target = $key1['target'];
$target_ip = gethostbyname($key1['target']);
}
}
} else {
$status = "mx recored not exist";
}
$c_by = 1;
$c_date = date('Y-m-d H:i:s');
$c_ip = $_SERVER['REMOTE_ADDR'];
$insert = $connect->query("INSERT INTO `email_verify_list`(`primary_email`,`host_name`,`target`,`target_ip`,`session`,`created_by`, `created_date`, `created_ip`) VALUES ('$abc','$host','$target','$target_ip','$c_ip','$c_by','$c_date','$c_ip')");
if($insert) {
$_SESSION['date_time'] = $c_date;
echo "<script>alert('successfully');</script>";
} else {
echo "<script>alert('!!!!!not successfully');</script>";
}
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8"/>
<meta charset="utf-8"/>
<title>BULK EMAIL VARIFIER</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"/>
<link rel="apple-touch-icon" href="pages/ico/60.png">
<link rel="apple-touch-icon" sizes="76x76" href="pages/ico/76.png">
<link rel="apple-touch-icon" sizes="120x120" href="pages/ico/120.png">
<link rel="apple-touch-icon" sizes="152x152" href="pages/ico/152.png">
<link rel="icon" type="image/x-icon" href="favicon.ico"/>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta content="" name="description"/>
<meta content="" name="author"/>
<link href="assets/plugins/pace/pace-theme-flash.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/bootstrapv3/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/jquery-scrollbar/jquery.scrollbar.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="assets/plugins/switchery/css/switchery.min.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="pages/css/pages-icons.css" rel="stylesheet" type="text/css" />
<link class="main-stylesheet" href="pages/css/pages.css" rel="stylesheet" type="text/css"/>
<!--[if lte IE 9]>
<link href="assets/plugins/codrops-dialogFx/dialog.ie.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
</head>
<body class="fixed-header ">
<div id="rootwizard" class="m-t-50">
<ul class="nav nav-tabs nav-tabs-linetriangle nav-tabs-separator nav-stack-sm">
<li class="active">
<a data-toggle="tab" href="#tab1"><span>EMAIL VERIFY</span></a>
</li>
</ul>
<form method="post" action="" >
<div class="tab-content">
<div class="tab-pane padding-20 active slide-left" id="tab1">
<div class="row row-same-height">
<div class="col-md-12">
<div class="padding-30">
<div class="row clearfix">
<div class="col-sm-3">
<div class="form-group form-group-default">
<label><font size="2">ENTER YOUR EMAIL <span class="glyphicon glyphicon-envelope"></span></font></label><br>
<textarea cols="43" rows="9" name="email_verify" style="border-color:white;border-width:thin;padding:4pt;" multiple/></textarea><br>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-3">
<button type="submit" name="email_verify_btn" class="btn btn-lg btn-info" style="padding:11pt;width:200px;"/><span><b><font size="2">SUBMIT</font></b></span></button>
</div>
</div> <br><br>
<div class="row clearfix">
<div class="col-sm-12">
<table width="100%" class="table ">
<tr class="success">
<th>PRIMARY EMAIL <span class="glyphicon glyphicon-envelope"></span></th>
<th>HOST NAME</th>
<th>TARGET</th>
<th>TARGET IP</th>
<th>STATUS</th>
</tr>
<?php
$select = $connect->query("SELECT * from `email_verify_list` where session='".$_SESSION['date_time']."' order by id");
while($row = $select->fetch_assoc()) {
?>
<tr>
<td><?php echo $row['primary_email']; ?></td>
<td><?php echo $row['host_name']; ?></td>
<td><?php echo $row['target']; ?></td>
<td><?php echo $row['target_ip']; ?></td>
<td><?php echo $row['status']; ?></td>
</tr>
<?php } ?>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<script src="assets/plugins/pace/pace.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="assets/plugins/modernizr.custom.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrapv3/js/bootstrap.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery/jquery-easy.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-unveil/jquery.unveil.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-bez/jquery.bez.min.js"></script>
<script src="assets/plugins/jquery-ios-list/jquery.ioslist.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-actual/jquery.actual.min.js"></script>
<script src="assets/plugins/jquery-scrollbar/jquery.scrollbar.min.js"></script>
<script type="text/javascript" src="assets/plugins/classie/classie.js"></script>
<script src="assets/plugins/switchery/js/switchery.min.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap3-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<script type="text/javascript" src="assets/plugins/jquery-autonumeric/autoNumeric.js"></script>
<script type="text/javascript" src="assets/plugins/bootstrap-tag/bootstrap-tagsinput.min.js"></script>
<script type="text/javascript" src="assets/plugins/jquery-inputmask/jquery.inputmask.min.js"></script>
<script src="assets/plugins/bootstrap-form-wizard/js/jquery.bootstrap.wizard.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-validation/js/jquery.validate.min.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js" type="text/javascript"></script>
<script src="assets/plugins/summernote/js/summernote.min.js" type="text/javascript"></script>
<script src="assets/plugins/moment/moment.min.js"></script>
<script src="assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
<script src="assets/plugins/bootstrap-timepicker/bootstrap-timepicker.min.js"></script>
<script src="pages/js/pages.min.js"></script>
<script src="assets/js/form_wizard.js" type="text/javascript"></script>
<script src="assets/js/scripts.js" type="text/javascript"></script>
<script src="assets/js/demo.js" type="text/javascript"></script>
<script>
window.intercomSettings = {
app_id: "xt5z6ibr"
};
</script>
</body>
</html>
Don't declare the function inside the loop.
Put this:
function domain_exists($abc)
{
$domain = substr(strrchr($abc, "#"), 1);
$arr = #dns_get_record($domain, DNS_MX);
if ($arr[0]['host'] == $domain && !empty($arr[0]['target'])) {
return $arr[0]['target'];
}
}
... before this line:
foreach ($text as $abc) {
Next, you need to declare the variables $target and $target_ip on the same level as you're trying to use them, i.e. on the same level as this line:
$insert = $connect->query("INSERT INTO `email_verify_list`(`primary_email`,`host_name`,`target`,`target_ip`,`session`,`created_by`, `created_date`, `created_ip`) VALUES ('$abc','$host','$target','$target_ip','$c_ip','$c_by','$c_date','$c_ip')")
The form contents are sent to my email but HTML and CSS code is not recognised on the email. Only plain text is outputted.
Below is my controller
public function registration() {
$email = $this->input->post('email');
$domain = $this->input->post('domain_name');
$passw = $this->input->post('passw');
$name = $this->input->post('name');
$skype = $this->input->post('skype');
// $package = $this->input->post('package');
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'xxxx.com',
'smtp_port' => 25,
'smtp_user' => 'xxx#xxxxxx.com',
'smtp_pass' => 'xxxxx',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('xxx#xxxxxx.com', 'welcome');
$this->email->to('xxxxx#xxxxxxxx.com');
$this->email->subject('registration');
$body = $this->load->view('dns/template', TRUE);
$this->email->message($body, TRUE);
$this->email->send();
$data['message'] = 'Submitted Sucessfullly';
$data['emails'] = $this->Dns_model->emails($domain);
$this->load->view('dns/sucessful', $data);
}
Below is my view saved as template.php
My view (template)
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<html> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Registration</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="<?php echo base_url()?>/assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="<?php echo base_url()?>/assets/css/bootstrap.css">
<link rel="stylesheet" href="<?php echo base_url()?>/assets/css/bootstrap-responsive.min.css">
<link rel="stylesheet" href="<?php echo base_url()?>/assets/css/font-awesome.min.css">
<link rel="stylesheet" href="<?php echo base_url()?>/assets/css/main.css">
<link rel="stylesheet" href="<?php echo base_url()?>/assets/css/style.css">
<link rel="stylesheet" href="<?php echo base_url()?>/assets/css/AdminLTE.css">
<link rel="stylesheet" href="<?php echo base_url()?>/assets/css/sl-slide.css">
<script src="<?php echo base_url()?>/assets/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
<!-- Le fav and touch icons -->
<link rel="shortcut icon" href="<?php echo base_url()?>/images/ico/favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="<?php echo base_url()?>/images/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="<?php echo base_url()?>/images/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="i<?php echo base_url()?>/mages/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="<?php echo base_url()?>/images/ico/apple-touch-icon-57-precomposed.png">
</head>
<body id="con" onLoad="generate();">
<div id="fb-root"></div>
<div class="container">
<section class="main-info">
<br>
<section id="recent-works3">
<section id="pricing-table">
<div class="row-fluid center clearfix">
<div class="span3">
</div>
<div class="span6">
<ul class="plan plan3">
<li class="plan-name">
<span class="lead3">Emails to be setup</span>
</li>
</ul>
<table class="table">
<thead>
<tr>
<th>Email</th>
<th>Password</th>
</tr>
</thead>
<tbody>
<tr class="info">
<td>info#test.com</td>
<td>terfwws6w</td>
</tr>
</tbody>
</table>
<ul class="plan plan3">
<li class="plan-action">
Registration website
</li>
</ul>
</div>
<div class="span3">
</div>
</div>
</section>
</section>
</section>
</div>
</div>
<script src="<?php echo base_url()?>/assets/js/vendor/jquery-1.9.1.min.js"> </script>
<script src="<?php echo base_url()?>/assets/js/vendor/bootstrap.min.js"></script>
<script src="<?php echo base_url()?>/assets/js/main.js"></script>
<script src="<?php echo base_url()?>/assets/js/jquery.ba-cond.min.js"></script>
</body>
</html>
I hope you are not using Parser library for email template, so bellow is my Answer by considering the above Condition.
You have problem with your template, means the Html code you wrote there, they have mismatched tag or some tag used in Wrong place. So you have to check that first.
If still you are not able to find out the problem then you just create a template using bellow code and You will see that the mail not more in normal text..
Nice, You nailed it...
NOTE: Don't use or etc tag and Also Use <table> instead of <div>
I'm including 'success.php' into 'create.php' but my php code on 'create.php' is getting auto-commented (html tag)
create.php
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<?php
require("header.php");
$amount = str_replace(array(".", ","), "", $_POST["amount"]);
$data = array(
"amount" => $amount,
"payment_method" => $_POST["payment_method"],
"customer" => $_POST["customer"],
"installments" => $_POST["installments"]);
if ($data["payment_method"] == "credit_card") {
$data += $_POST["card"];
}
try {
$transaction = new PagarMe_Transaction($data);
$transaction->charge();
require("success.php");
} catch(Exception $e) {
echo $e->getMessage();
}
?>
</body>
</html>
success.php
<div class="container" style="padding-bottom:100px">
<div class="page-header">
<h1>Guide Life</h1>
</div>
<div class="alert alert-success" role="alert">
<b>Transação efetuada com sucesso!</b>
</div>
<? if ($transaction->payment_method == "boleto") { ?>
<p>
Link para o boleto:
<a target="_blank" href=""></a>
<iframe src="https://api.pagar.me/1/boletos/live_citxbiz9d0kg9gu3e33cwmdwr" width="100%" height="100%" />
</p>
<? } ?>
</div>
Page:
Html code generated:
<? if ($transaction->payment_method == "boleto") { ?>
Needs to have the correct open tag <?php same with <? } ?> should be <?php } ?>